r/java • • 29d ago

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

MetricSpring BootJavalin + Jdbi
Median app RSS186.9 MiB159.1 MiB
Readiness3.79 s2.72 s
HTTP p955.54 ms5.59 ms
Successful requests1,500/1,5001,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.

MetricSpring BootJavalin + Jdbi
Median app RSS107.0 MiB65.5 MiB
Readiness0.183 s0.113 s
HTTP p954.84 ms4.34 ms
Minimum host MemAvailable204.9 MiB204.1 MiB
Successful requests1,500/1,5001,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?

36 Upvotes

13 comments sorted by

5

u/Paw565 29d ago

I love your posts. Keep doing the good work.

2

u/fykup 29d ago edited 29d ago

Thank you, it means a lot! 🙂

r/java has been a tough but rewarding community for me. Even a slightly unfortunate title can attract plenty of downvotes and harsh comments, but I've also had some of the most insightful discussions here. Interestingly, some of my best articles have attracted both strong criticism and positive feedback. I've learned quite a bit from both.

Java has been a big part of my professional life. I want to keep exploring how Java is evolving, learning new things, and sharing what I've learned over the years. That's why I keep coming back here, even when the reception is a little rough 🙂

1

u/[deleted] 29d ago

[removed] — view removed comment

1

u/fykup 29d ago

Fair point! This experiment focused on constrained VPS deployments, and the extra noise is a tradeoff of that setup. As I mentioned in another comment, I'm planning more formal web app benchmarks, where using at least 2 vCPUs and multiple runs would make more sense.

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.

1

u/fykup 27d ago

Thanks! The point about reassembling Spring Boot's integrated pieces is exactly what I'm exploring next. I've been experimenting with Avaje Jex + Jdbi and a thin integration layer that removes much of the boilerplate around transactions, configuration, health checks, and lifecycle management, while keeping application wiring explicit.

The goal is to see how much of Spring Boot's convenience we can retain with a significantly smaller footprint. More experiments and benchmarks to come.

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

2

u/fykup 29d ago edited 29d ago

Thanks for the suggestions! Compact Object Headers are already enabled by default in JDK 27.

I don't run benchmarks just for the sake of benchmarking. My broader focus is efficient Java deployments on small VPS instances, including JVM tuning, lightweight frameworks, database access, and application monitoring (which is also why I built StatLite).

And efficiency isn't just about memory usage or runtime performance. Development productivity matters too. For example, GraalVM Native Image offers impressive memory savings, but its build times are a significant trade-off.

I actually like Spring Boot and will probably continue using it. But it also comes with some complexity and overhead I don't always need, so I'm exploring alternatives and ways to assemble a leaner Java stack without sacrificing developer productivity.

That's the direction behind these experiments, rather than benchmarking every language or optimization out there. Plenty of interesting cross-language comparisons already exist!

1

u/CutGroundbreaking305 29d ago

I understand but the reason why I say try others is not because for the sack of just trying them. See how other languages and frameworks do we can learn a lot of new things and make changes accordingly and understand is there a room for further optimizations.

I made a pure Java numeric library in similar way checking how others do and trying to check if we can optimise it further (it is headache but fun). That is why I can get close to native wrappers like numpy.JNum (once try it out if you want to not a promotion I don't get anything 🙂)

I trying to make efficient Java myself idk how successful I will be. But seeing others will help you understand where we lack the most.

2

u/fykup 29d ago

I get your point 🙂 Cross-language comparisons definitely have value when there's a specific question to answer. For example, I also maintain Scriptella ETL and have benchmarked it against JDBC, Python-based tools, and native database loaders. That's where those comparisons make sense.

But there's already plenty of cross-language benchmarking out there. I think DHH has given us enough Ruby vs. Rust comparisons to keep us busy for a while 🙂

Right now I'm more interested in exploring how lean and practical we can make Java itself, especially for small VPS deployments. There's quite a bit to investigate within the Java ecosystem alone!

Maybe I'll expand into other languages and frameworks later, but for now I'd rather keep the scope manageable. Otherwise benchmarking could easily become a full-time job 🙂

2

u/CutGroundbreaking305 29d ago

I like how u 🙂🙂🙂 🙂

1

u/fykup 29d ago

On a more serious note, I do agree with your point. I'm planning a more formal benchmarking project and accompanying article, building on my recent experiments. Initial candidates include Spring Boot, Micronaut, Quarkus, and Javalin.

That's where I'd also consider rewriting the same application in other languages or frameworks, since the goal would be a proper comparative benchmark suite with consistent workloads and methodology.

No timeline yet, but it's something I'm actively exploring. 🙂