lettuce icon indicating copy to clipboard operation
lettuce copied to clipboard

Latency while reusing redis client

Open IdanFridman opened this issue 9 years ago • 0 comments

I am using the same RedicClient(as recommended) for couple of connections types. and I am having huge latency issues while using them in parallel:

using biz.paluch.redis:lettuce:4.0.Beta2

    private RedisClient client;
    private StatefulRedisConnection<String, String> connection;
    private RedisCommands syncCommands;
    private RedisGeoAsyncCommands<String, String> geoAsyncCommand;
    private RedisAsyncCommands<String, String> asyncCommands;
    private RedisCommands<String, String> redisSyncConnection;
  @PostConstruct
    public void init() {
        log.debug("RedisRepo, Init.");
        client = new RedisClient(REDIS_HOST, REDIS_PORT);
        connection = client.connect();
        connection.setTimeout(10, TimeUnit.SECONDS);
        syncCommands = connection.sync();
        syncCommands.setTimeout(4, TimeUnit.SECONDS);
        geoAsyncCommand = client.connect().async();
        //  RedisClusterClient clusterClient = new RedisClusterClient(new RedisURI(REDIS_HOST,REDIS_PORT,60, TimeUnit.SECONDS));
        asyncCommands = client.connect().async();
        redisSyncConnection = client.connect().sync();
    }

and I have separate methods being invoked with diff Redis commands in parallel

Latency report: ]$ /opt/redis-unstable/src/redis-cli --intrinsic-latency 100 Max latency so far: 1 microseconds. Max latency so far: 32 microseconds. Max latency so far: 8147 microseconds. Max latency so far: 8217 microseconds. Max latency so far: 12169 microseconds. Max latency so far: 12182 microseconds. Max latency so far: 12199 microseconds. Max latency so far: 12223 microseconds. Max latency so far: 12255 microseconds. Max latency so far: 12298 microseconds. Max latency so far: 12303 microseconds. Max latency so far: 12310 microseconds. Max latency so far: 12330 microseconds.

253109899 total runs (avg latency: 0.3951 microseconds / 3950.85 nanoseconds per run). Worst run took 31208x longer than the average latency.

  1. Am I using the Redis Client properly?
  2. Is it the right way to use multiple connection types with the same RedisClient?

Thanks.

IdanFridman avatar Feb 16 '16 14:02 IdanFridman