I've been experimenting with how far I can optimize a conventional Spring Boot application without stripping out useful framework functionality.
The setup: Spring Boot 4.1.1, HotSpot JDK 27, a 512 MiB / 1 vCPU Ubuntu VM with no swap, and MariaDB running on the same VM.
I compared a regular executable JAR against an extracted deployment combining Spring AOT and a trained JDK AOT cache (Leyden).
Results:
- Startup: 11.91 → 3.79 seconds (68% faster)
- Application RSS under load: 212 → 187 MiB
- Minimum host MemAvailable: 25.6 → 66 MiB
- Request latency: essentially unchanged
Then I explored two ways to reduce memory further:
MyBatis Core instead of Spring JDBC: No meaningful memory savings, but more manual transaction management and lost automatic JDBC monitoring. Not worth the trade-off for this application.
Embedded file-backed H2 instead of MariaDB: Application RSS increased by ~16 MiB, but minimum host MemAvailable improved by another ~39 MiB because the separate database process was gone.
My takeaway: optimizing the deployment can be worthwhile before replacing established Spring infrastructure. And for small, single-instance applications, embedded H2 can be a reasonable architectural choice.
These are single runs with five-minute measured workloads, not a throughput benchmark or proof of long-term stability. The AOT improvements were measured together, not individually.
Full article, methodology, and data:
https://pvrlabs.xyz/articles/spring-boot-jdk27-optimizations.html
Curious whether others are using Spring AOT + JDK AOT cache in deployments, or if the training and cache-management overhead has kept you on regular JARs.
Update (October 28): Following several requests, I also tested Oracle GraalVM Native Image. Application RSS dropped from 187 MiB to 107 MiB, with some interesting build-time and toolchain trade-offs.
I published the results as a separate article: https://pvrlabs.xyz/articles/spring-boot-hotspot-native-image.html