Skip to content

Revisit performance bottlenecks in hot code paths using Lettuce through the reactive Template #2110

Closed
@vinsguru

Description

@vinsguru

I was trying to run this simple performance test with Spring Data Redis vs lettuce.

Spring Data Redis seems to be significantly slow with default configuration compared to lettuce. (The throughput is 50% less with Spring Data Redis). Is this much difference expected?

You can check yourself wit this code.

Spring Boot : 2.5.2
spring-boot-starter-data-redis-reactive

   @RepeatedTest(3)
    public void springDataRedisPerformance(){
        ReactiveValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
        long before = System.currentTimeMillis();
        Mono<Void> mono = Flux.range(1, 500_000)
                .flatMap(i -> valueOperations.increment("user:1"))
                .then();
        StepVerifier.create(mono)
                .verifyComplete();
        System.out.println((System.currentTimeMillis() - before) + " ms");
    }

    @RepeatedTest(3)
    public void lettucePerformance() throws InterruptedException {
        RedisClient redisClient = RedisClient.create("redis://localhost:6379/0");
        StatefulRedisConnection<String, String> connection = redisClient.connect();
        RedisReactiveCommands<String, String> reactiveCommands = connection.reactive();

        long before = System.currentTimeMillis();
        Mono<Void> mono = Flux.range(1, 500_000)
                .flatMap(i -> reactiveCommands.incr("user:1"))
                .then();

        StepVerifier.create(mono).verifyComplete();
        System.out.println((System.currentTimeMillis() - before)  + " ms");
    }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions