vert-x3 / vertx-redis-client

Redis client for Vert.x
http://vertx.io
Apache License 2.0
131 stars 119 forks source link

hight cpu usage after pressure test #385

Closed dreamlike-ocean closed 1 year ago

dreamlike-ocean commented 1 year ago

Questions

I are comparing vertx-redis and lettuce, both of which are one verticle and one redis connection. The test content is very simple. This http interface will serially initiate 10 redis get requests. Then, it will use this wrk -c100 -t4 -d60s --latency http://localhost:8080/vertx-redis command to perform three pressure tests. After the pressure test, 4.4.1 vertx-redis has a memory surge problem, 4.4.2 memory is normal, and both have high CPU usage problems after the pressure test. Jstack found that when processing various responses of Redis, is this abnormal memory + high CPU usage a bug? The test code and jfr are in this repository https://github.com/dreamlike-ocean/vertx-redis-test/tree/master.

Version

4.4.2

Extra

Java version: 20.0.1, vendor: Oracle Corporation, runtime: /home/dreamlike/jdk-20.0.1 Default locale: en, platform encoding: UTF-8 OS name: "linux", version: "6.3.1-ivan-nbd-2023-compatible 6.x", arch: "amd64", family: "unix"

tsegismont commented 1 year ago

Thanks for reporting this. We'll look into it. In the meantime, can you add instructions in the reproducer project for:

dreamlike-ocean commented 1 year ago

building: mvn clean package -DskipTests; starting Redis: docker run --name redis-test -d redis executing the application: java -jar target/demo-0.0.1-SNAPSHOT.jar

tsegismont commented 1 year ago

Everyhing on the same machine? No heap sizing for the JVM?

dreamlike-ocean commented 1 year ago

yes,Everyhing on the same machine and No heap sizing for the JVM。 It's too strange, I have this problem when I use vertx-redis, but lettuce doesn't. I have repeatedly tested this n times. From the collected jfr data, even after the pressure test is over, eventloop is still processing redis requests.

tsegismont commented 1 year ago

Can you change this:

        router.get("/vertx-redis")
            .handler {
                val context = vertx.orCreateContext
                CoroutineScope(context.dispatcher()).launch {
                    for (index in 1..10) {
                        vertxClient.get("123").await().toString()
                    }
                }
                it.end(Thread.currentThread().toString())
            }

To:

        router.get("/vertx-redis")
            .handler {
                val context = vertx.orCreateContext
                CoroutineScope(context.dispatcher()).launch {
                    for (index in 1..10) {
                        vertxClient.get("123").await().toString()
                    }
                    it.end(Thread.currentThread().toString()) // <- the response shall be sent in the coroutine after all responses have been received
                }
            }
dreamlike-ocean commented 1 year ago

Can you change this:

        router.get("/vertx-redis")
            .handler {
                val context = vertx.orCreateContext
                CoroutineScope(context.dispatcher()).launch {
                    for (index in 1..10) {
                        vertxClient.get("123").await().toString()
                    }
                }
                it.end(Thread.currentThread().toString())
            }

To:

        router.get("/vertx-redis")
            .handler {
                val context = vertx.orCreateContext
                CoroutineScope(context.dispatcher()).launch {
                    for (index in 1..10) {
                        vertxClient.get("123").await().toString()
                    }
                    it.end(Thread.currentThread().toString()) // <- the response shall be sent in the coroutine after all responses have been received
                }
            }

thank you,that is my fault