redis / lettuce

Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
https://lettuce.io
MIT License
5.36k stars 959 forks source link

Redis cluster using lettuce sometimes get command slow #2461

Open zlp1992 opened 1 year ago

zlp1992 commented 1 year ago

I'm using spring-data-redis and lettuce in redis cluster. here is the code:

    @Bean
    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
        RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
        template.setConnectionFactory(factory);
        template.setKeySerializer(RedisSerializer.string());
        template.setHashKeySerializer(RedisSerializer.string());
        template.setValueSerializer(RedisSerializer.json());
        template.setHashValueSerializer(RedisSerializer.json());
        template.afterPropertiesSet();
        return template;
    }

and after debug, factory is: 666666666

but sometimes,redisTemplate.opsForValue().get cost high, is there any ideas?

mp911de commented 1 year ago

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem.

zlp1992 commented 1 year ago

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem.

Hi, we use spring-boot-starter-data-redis(version 2.6.6) and all with default config. we use SpringTemplate

    public <T> T getCacheObject(final String key) {
        ValueOperations<String, T> operation = redisTemplate.opsForValue();
        return operation.get(key);
    }

but sometime the time spend on method getCacheObject cost almost 1 seconds(through from trace system). still have no idea about or to reproduces the problem. as we can see from pinpoint the gap of AbstractRedisAsyncCommandsis high 7777777

zlp1992 commented 1 year ago

By the way. if using redis cluster, whether there is only one native shared connection for all node of the cluster or one native shared connection for one node in the cluster?