We recently upgraded our application to Spring Boot 2 (2.0.3.RELEASE). Along with that Spring Data Redis was upgraded was upgraded to 2.0.8.RELEASE. We switched over from using Jedis to Lettuce as the boot upgrade docs say that is now the default.
I have the lettuce connection pool defined as:
spring:
redis:
ssl: true
lettuce:
pool:
max-active: 250
max-idle: 250
min-idle: 50
max-wait: 2000ms
shutdown-timeout: 100ms
I noticed today on one of the dev servers, we are getting a lot of thread blocking while doing Redis read/writes. The path looks like this:
io.lettuce.core.internal.AbstractInvocationHandler:invoke:80
|
|__io.lettuce.core.FutureSyncInvocationHandler:handleInvocation:62
|
|__io.lettuce.core.LettuceFutures:awaitOrCancel:112
|
|__io.lettuce.core.protocol.AsyncCommand:await:81
|
|__java.util.concurrent.locks.LockSupport:parkNanos:215
Sometimes we see the thread waiting for 2 seconds and some times we see it for 19 seconds.
I started looking into different options for Spring Redis like pipelining.
https://github.com/lettuce-io/lettuce-core/wiki/Asynchronous-API
The problem that I'm running into is that I can't find a way to get the LettuceConnection to be asynchronous. I see that LettuceConnection.getAsyncConnection() is called when pipelining. And from what I can tell, pipelining is only available when you use RedisTemplate. As of Spring Data Redis 2, RedisCacheManager does not use RedisTemplate anymore; it uses RedisCacheConfiguration.
So, my question is how do we do Async Redis using the Spring Cache Abstraction (RedisCacheManager)?