Without further ado, get straight to the picture above:This is the project in the online log, check has not found a large amount of log what rule, occasionally will quote this wrong, then a visit to normal again next time, check a lot of data did not find why lettuce will appear this problem!
Solutions:
Change the lettuce driver directly to jedis, and it works!
<! -- redis start --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <exclusions> <exclusion> <groupId>io.lettuce</groupId> <artifactId>lettuce-core</artifactId> </exclusion> </exclusions> </dependency> <! Commons -pool2</artifactId> Commons -pool2</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>redis. Clients </groupId> The < version > 2.10.2 < / version > < / dependency >Copy the code
Configuration file changes:
spring.redis.jedis.pool.max-idle=200
spring.redis.jedis.pool.min-idle=100
spring.redis.jedis.pool.max-active=200
spring.redis.jedis.pool.max-wait=1000
Copy the code
Spring-data-redis has two built-in drivers, Jedis and lettuce. The springboot2.X version defaults to the jedis implementation and the Spring Boot2. X defaults to the lettuce implementation.
Lettuce: Netty based implementation, thread-safe, but only one instance by default.
Jedis: directly connects to the Redis server. It is generally used with connection pools to add physical connections.
In regards to the lettuce problem, many methods have been tried (increasing the time-out timeout no matter how long the timeout is set, if the connection is broken, the connection will not be reconnected), There is no concrete evidence that the server may have a problem with the oracle version or that TCP resetting of the server load balancer causes the connection to break.
Associated problems
This problem, just from some online concurrency is not high interactivity is also less important simple activities, up to affect the user experience, so that the test did not test the question before, but if you use redis as a distributed lock, this is a very fatal problem, timeout will directly cause the failure of a distributed lock acquisition, A series of related problems (are the experience of tears, fishing log fishing to vomit), take warning, said the wrong welcome correction!