Software Development Community Question

Is it worth migrating our legacy monolith from Java 8 to Java 21 for the ZGC performance?

Posted on 2025-01-12 • In Software Development • By Kevin Adams

Our core banking application is still stuck on Java 8 because we are afraid of breaking our RMI and serialization logic. However, we are struggling with 2-second "Stop-the-World" garbage collection pauses. Would upgrading to Java 21 and using the Z Garbage Collector (ZGC) eliminate these latency spikes without requiring a total rewrite of our memory management?

3 Answers 14,276 Views

All answers to this question 3 Answers

Barbara King Answered on 2025-01-15
Answered

The jump from Java 8 to 21 is significant, mostly due to the Module System introduced in Java 9. Once you get past the dependency issues, ZGC is like magic for large heaps. It is designed to keep pause times under 1 millisecond, regardless of whether your heap is 1GB or 1TB. In our migration, our 99th percentile latency dropped from 1500ms to under 10ms. You don't even need to do much tuning; just set -XX:+UseZGC and let the JVM handle the rest. It’s the single biggest reason to upgrade your legacy enterprise systems today

Jeffrey Vance Answered on 2025-01-17
Answered

Are you using any third-party libraries that rely on 'Unsafe' or internal Sun packages? Java 21 is much stricter about "Illegal Access," which could be a bigger blocker than the GC config.

Kevin Adams Commented on 2025-01-20
Commented

Jeffrey, we did find some issues with an old caching library. We had to use some --add-opens flags in our startup script to get it to run, but it’s a temporary fix while we look for a modern alternative. The performance boost from ZGC on our 64GB heap was so massive that management is okay with these minor configuration workarounds for now. It has completely solved our "jitter" issues during peak trading hours, which was our primary goal.

Maria Hernandez Answered on 2025-01-22
Answered

Don't forget the 'Generational ZGC' feature in Java 21. It handles short-lived objects much more efficiently than the original version, further reducing the CPU overhead of the collector.

Barbara King Commented on 2025-01-25
Commented

Maria is right. Generational ZGC makes the collector viable for even more workloads, as it handles the "infant mortality" of objects without scanning the whole heap.

Write a Comment

Your email address will not be published. Required fields are marked (*)

Join the LearnersEra Community

Ask questions, share knowledge and learn from professionals across technology, project management and certification topics.

Change Country and Nearest City

Select your country and nearest city to see courses available in your region.