Skip to content

Large CPU usage increase with Java 21 #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MichaelPluessErni opened this issue Apr 11, 2025 · 6 comments
Open

Large CPU usage increase with Java 21 #182

MichaelPluessErni opened this issue Apr 11, 2025 · 6 comments

Comments

@MichaelPluessErni
Copy link

When switching from Java 17 to Java 21 we noticed a big increase in CPU usage on our Google Cloud instances.

Image Image

The increased usage disappeared again when we disabled the Kubernetes Kit.

Apparently, the serialization process of the Kubernetes Kit uses much more computing power with Java 21 than with Java 17.

The versions we are using:

spring-boot: 3.4.4
vaadin: 24.6.7
kubernetes-kit-starter: 2.4.1
kubernetes: 1.31

@mcollovati
Copy link
Contributor

@MichaelPluessErni do you have any particular JVM settings, for example for garbage collection?

@MichaelPluessErni
Copy link
Author

@mcollovati We did have them. But we removed those and it made no difference:
"application.JDK_JAVA_OPTIONS": "\"-XX:+UnlockExperimentalVMOptions -XX:InitiatingHeapOccupancyPercent=30 -XX:G1MixedGCLiveThresholdPercent=85 -XX:G1OldCSetRegionThresholdPercent=25\""

@gtzluis
Copy link

gtzluis commented Apr 23, 2025

are you by any chance using JDK 21.0.3 or earlier? there was an issue with garbage collection, addressed in JDK 21.0.4.
https://bugs.openjdk.org/browse/JDK-8333832

@MichaelPluessErni
Copy link
Author

Hi Luis

We have version 21.0.6 of Java Temurin running on our pods. The issue persists.

openjdk version "21.0.6" 2025-01-21 LTS
OpenJDK Runtime Environment Temurin-21.0.6+7 (build 21.0.6+7-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.6+7 (build 21.0.6+7-LTS, mixed mode, sharing)

@MichaelPluessErni
Copy link
Author

We tried disabling the Kubernetes Kit and the CPU limit utilization went back to pre-Java 21 levels:

Image

(Kubernetes Kit disabled on night from 29. to 30. April)
This confirms that the utilization increase originates from the interaction between the Kubernetes Kit and Java 21.

@mcollovati
Copy link
Contributor

I did some tests locally (Redis backend), but I cannot see any difference in terms of CPU usage between 17 and 21.
No peaks, even if I quickly scroll up and down a Grid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants