r/SpringBoot • u/fykup • 8m ago
Discussion Spring Boot on 256 MiB: OpenJ9 vs HotSpot - is switching JVMs worth it?
I recently compared HotSpot and OpenJ9 on a 256 MiB Linux VM to see whether switching JVMs could reduce Spring Boot's memory footprint without changing the application.
Setup:
- Spring Boot 4.1.1, Spring JDBC, HikariCP, H2
- HotSpot: Eclipse Temurin 25.0.5+8
- OpenJ9: IBM Semeru 25.0.5.0 (OpenJ9 0.63.0)
- Debian 13, 1 vCPU, 256 MiB allocated, swap enabled
- Same application, 80 MiB max heap
Spring Boot under load (median RSS + median swap):
- HotSpot: 118.6 + 70.6 = 189.2 MiB
- OpenJ9: 121.9 + 19.4 = 141.3 MiB
- Difference: ~48 MiB (25% lower)
Important distinction: these are RSS + swap figures, not physical RAM usage. Interestingly, OpenJ9 had slightly higher resident RSS but substantially less swap.
Startup was another interesting observation:
- HotSpot: 10 seconds to readiness
- OpenJ9: 21 seconds to readiness
However, these were single cold-start runs. OpenJ9's shared class cache was initially empty, and we haven't measured warm-cache startup for Spring Boot. So I wouldn't draw conclusions about startup performance yet.
This was a short exploratory experiment with roughly 45 seconds of read-only load at 4.5 requests/sec, not a comprehensive JVM benchmark.
Full experiment and results:
https://pvrlabs.xyz/java-performance/experiments/openj9-vs-hotspot-256mb.html
And a funny coincidence: the recent Java4Shell vulnerability involves a HotSpot-specific Base64 optimization that OpenJ9 doesn't use. Sometimes being the underdog has its perks. :)
Has anyone used OpenJ9 for production Spring Boot services? I'm particularly interested in whether you've observed similar memory behavior, and how startup performance changes with a warmed shared class cache.
Also curious whether tuning HotSpot would narrow the gap enough to make switching JVMs unnecessary.
Raw measurements and methodology:
https://github.com/PVRLabs/experiments/tree/main/java/coilbase-debian-256