Spring Boot vs Javalin + Jdbi: HotSpot and GraalVM on a 512 MiB VM
I've been experimenting with how far a small Java backend can be trimmed down while keeping useful application structure.
After optimizing a Spring Boot 4 application with Spring AOT and a JDK AOT cache, I rebuilt the same database-backed Market Replay application using Javalin 7 and Jdbi.
Both ran on a 512 MiB / 1 vCPU VM without swap, alongside MariaDB and a small HTTP quote fixture. The application periodically ingests quotes into MariaDB and serves latest-price and history endpoints.
HotSpot JDK 27
| Metric | Spring Boot | Javalin + Jdbi |
|---|---|---|
| Median app RSS | 186.9 MiB | 159.1 MiB |
| Readiness | 3.79 s | 2.72 s |
| HTTP p95 | 5.54 ms | 5.59 ms |
| Successful requests | 1,500/1,500 | 1,500/1,500 |
Javalin used 27.8 MiB (14.9%) less application RSS, with similar latency at the tested load.
GraalVM Native Image (JDK 25)
Both applications were also compiled using Oracle GraalVM 25 at the same O2 optimization level.
| Metric | Spring Boot | Javalin + Jdbi |
|---|---|---|
| Median app RSS | 107.0 MiB | 65.5 MiB |
| Readiness | 0.183 s | 0.113 s |
| HTTP p95 | 4.84 ms | 4.34 ms |
| Minimum host MemAvailable | 204.9 MiB | 204.1 MiB |
| Successful requests | 1,500/1,500 | 1,500/1,500 |
The native results were particularly interesting: Javalin used 41.5 MiB less application RSS, but available host memory was almost identical. Lower process RSS doesn't always translate into more usable memory for the VM.
Beyond the numbers
The main tradeoff wasn't just performance.
Spring Boot provides integrated MVC, persistence, transactions, health checks, metrics and application wiring. With Javalin, these responsibilities need to be assembled explicitly.
For persistence, I used Jdbi with a small experimental repository abstraction providing SQL selection and explicit transaction callbacks. I've published the experiment source and transaction tests alongside the measurements, and I'm interested in feedback on whether these conventions add value over plain Jdbi.
These are single-run comparisons of complete application stacks, not isolated framework benchmarks or throughput tests. HotSpot uses JDK 27, while Native Image uses JDK 25.
Full article (charts, methodology, and discussion):
https://pvrlabs.xyz/articles/spring-boot-vs-javalin-jdbi.html
Experiment source and results:
https://github.com/PVRLabs/experiments/tree/main/javalin/market-replay-jdk27
Jdbi persistence source and transaction tests:
https://github.com/PVRLabs/experiments/tree/main/javalin/market-replay-jdk27/persistence-example
For smaller Java services, do you prefer Spring Boot's integrated approach, or lighter frameworks where you assemble the pieces yourself?
5
u/Paw565 29d ago
I love your posts. Keep doing the good work.
1
u/Financial_Morning386 28d ago
Thanks for publishing the full methodology — the most useful result here isn't the 28 MiB RSS gap, it's that p95 latency is essentially identical (5.54 ms vs 5.59 ms on HotSpot) and that the native-image RSS advantage didn't move host MemAvailable at all. That tells me memory alone shouldn't decide this choice for a service shaped like yours.
My rule of thumb from building Spring Boot backends is to stay with Spring Boot when the service needs the integrated pieces — declarative transactions, security, Actuator health checks and metrics, and configuration management — or when several people will maintain it, because those are the things you end up re-assembling by hand on a lighter stack. Javalin + Jdbi earns its place when the service is small and single-purpose, has few endpoints, and you are comfortable wiring health checks, structured logging, graceful shutdown, and transaction and connection-pool boundaries yourself.
Two costs I would weigh before going native: GraalVM build time and reflection/resource configuration, plus harder debugging when a dependency isn't native-ready, only pay off if startup time is a hard requirement — for example scale-to-zero or short-lived jobs. For a long-running service that already fits in 512 MiB on HotSpot, I would usually take the 3.79 s startup and keep the ecosystem.
One measurement caveat: 1,500 requests is fine for RSS and readiness, but I would not conclude latency parity from it. A sustained-load run that saturates the connection pool and exercises GC would tell you more about the tail. For this workload, I would pick Spring Boot on HotSpot unless fast cold start is a requirement.
0
u/CutGroundbreaking305 29d ago
Use JDK 27 compact object headers or use FFM whichever it is(sorry didn't see u used 27 hotspot noice)
Also maybe unconventional use SIMD Vector api that will make Java performance on par to native
And try benchmarking with other languages as well like axum/rust java-http fastapi/python node-http go kotlin etc and see