Skip to content

Spring Boot RSocket high CPU usage after client disconnects #992

Description

@mister11

Origin of this issue is StackOverflow post where I showed some code, but I'll add more details here.

Expected Behavior

After a client is shut down, CPU usage should not increase especially not to >50%.

Actual Behavior

When using the latest version of Spring Boot and its RSocket support (which pulls rsocket-java version 1.1.0), after a client requests a stream of data and it disconnects (manual termination of the client application or Ctrl+C of the rsc CLI), CPU usage gets high (~20%). If more clients are connected and disconnected, CPU usage grows even higher (theoretically it could reach 100% with enough clients).

Steps to Reproduce

I'm attaching Spring Boot application. It's an unfiltered version, meaning I haven't change anything from the point in time when CPU usage was behaving as described. sample-service.zip

Once this service is running, I opened few terminals and run rsc tcp://localhost:8888 --stream --route test in each of them. After ~10 seconds I'd start closing it one by one. As I'm closing them, I can see CPU usage in htop increasing and finally stopping at around 70-80%. Only after service is shut down, CPU usage drops to an idle state. Maybe it's not important, but I had to click that red skull icon in IntelliJ since the application did not properly shut down only with the red square.

Just for the case of completeness, I'm attaching rsocket-kotlin sample-client.zip that can be used to reproduce the same behavior. For this, it's enough to just start/stop the client couple of times.

Your Environment

Arch Linux with Java 13 (uname -a: Linux tara 5.4.39-1-MANJARO #1 SMP PREEMPT Wed May 6 10:36:44 UTC 2020 x86_64 GNU/Linux)
Spring Boot 2.4.3, Kotlin + JVM 11 as a target
RSocket Java 1.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions