r/java • • 8h ago

Benchmarking Java frameworks on a 512 MiB server: Spring Boot, Quarkus, Micronaut and Jex

Post image

I've been experimenting with Java applications on memory-constrained servers and have now formalized these comparisons into a reproducible benchmark.

One particularly interesting finding: despite substantial differences in memory consumption and startup time, all four stacks delivered remarkably similar p99 latency under sustained load.

The first published results compare four stacks implementing the same investment portfolio service:

  • Spring Boot + JDBC
  • Quarkus + Jdbi
  • Micronaut Data JDBC
  • Jex + Jdbi

Each application runs alongside PostgreSQL 18.7 on a 512 MiB Debian 13 VM with 1 vCPU, no swap and HotSpot 27 (-Xms16m -Xmx80m -XX:+UseG1GC).

Key results:

  • All eight runs sustained 40 requests/sec without errors or timeouts.
  • Sustained p99 latency ranged from 11.02 to 11.51 ms.
  • Sampled peak application RSS ranged from 148 to 233 MiB.
  • Application readiness ranged from 4.64 to 10.82 seconds.

The benchmark uses shared correctness checks, a versioned protocol, recorded measurements and automated report generation.

Spring Boot + JDBC is the reference implementation, and the other implementations reproduce its application behavior. The benchmark compares complete SQL-first application stacks rather than isolated framework overhead. The goal is to understand practical trade-offs under realistic resource constraints.

I'm also the author of CoilBase, which the Jex and Quarkus implementations use as a thin integration layer around Jdbi. Given its simple implementation, I expect its overhead to be negligible. It hasn't been measured separately, but I'd be happy to run an isolated comparison if there's interest.

Article: https://pvrlabs.xyz/java-performance/experiments/benchmarking-java-frameworks-512mib.html

Benchmark source: https://github.com/PVRLabs/framework-benchmarks

I'm currently considering two directions for the next comparison:

  • Add Helidon to broaden the Java framework comparison.
  • Add a Go implementation as a first cross-language comparison, opening the door to community contributions in other languages, such as Rust.

Which direction would you find more interesting? Other suggestions are welcome too.

25 Upvotes

19 comments sorted by

3

u/mands 6h ago

Super interesting - would love to see Helidon in these benchmarks - found it very lightweight

1

u/fykup 6h ago

Thanks! Helidon is definitely on my list. I'll try to publish an updated benchmark with Helidon before Christmas.

0

u/fykup 6h ago

I'm planning to use Jdbi for persistence unless there's a preferred Helidon-specific alternative. I like Jdbi's transaction management and low memory overhead, and it makes it relatively easy to reproduce Spring Boot's JdbcTemplate and '@Transactional' behavior.

Is there another persistence layer you'd recommend for Helidon?

1

u/ah3nan 3h ago

I would recommend Helidon 27 with Doma.

3

u/Svellere 3h ago

Just a tip, when making benchmark charts, it's best practice to denote whether higher or lower is better.

2

u/fykup 3h ago

Great point, thanks! I'll update both the charts and the report generator to indicate whether higher or lower is better for each metric.

2

u/TheKingOfSentries 5h ago

Since Jex is pretty much a wrapper on the jdk's built-in server, it's quite interesting to see how competitive it is in these benchmarks. Have you tried using jex with the other httpserver implementations?

3

u/fykup 3h ago

I actually discovered Jex by accident while exploring lighter alternatives to Spring Boot. I had already experimented with Javalin and decided to give Jex a try. To my surprise, it used even less RAM.

I also liked Avaje HTTP as an abstraction. It aligned well with my idea of building a Spring Boot-like development experience without the heavier runtime.

I'm aware of the alternative HTTP server implementations but haven't tested them yet. My guess is that some could offer better throughput, though not necessarily a smaller memory footprint. I've been pleasantly surprised by how well the JDK's built-in HTTP server performs.

If there's enough interest, I'd be happy to benchmark the alternative implementations as well.

2

u/jonenst 4h ago

I'd be interested in the numbers you get when using  -XX:TrimNativeHeapInterval=10000 since this is debian13 (glibc). Notably it reclaims memory from the startup (compilations) which is otherwise stuck behind malloc. I don't think it changes the kind of performance (even p99) you are testing at 40rps.

And When memory is more important than performance (for 40rps this should be the case) (although I have not seen any catastrophic performance drop from this) I even use -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 - G1PeriodicGCInterval=10000

If you don't maybe one day i'll try and reproduce your benchmarks and for your benchmarks see what they do!

1

u/fykup 3h ago

Thanks, these are great suggestions! This is exactly the kind of experimentation I'd like the benchmark to support.

I'll add a guide explaining how to reproduce the current benchmark with custom JVM settings, so people can easily fork the repository, try different optimizations and share their results without changing the standard benchmark configuration.

I'd be particularly interested in seeing what native heap trimming does to RSS in this setup.

1

u/Unfair_Ad8967 7h ago

Would be great to see those servers running on GralVM if supported. Plus for memory constrained servers we should make sure we disable unnecessary subsystems like metrics collection, logging, etc.

2

u/Joram2 6h ago

GraalVM is not formally deprecated, but Oracle is clearly moving away from it as a strategic Java runtime. Oracle is steering Java developers toward standard OpenJDK technology, particularly Project Leyden.

No, don't bother benchmarking it.

I would like to see Quarkus 4.0, Helidon 27, Golang, and Rust benchmarks :)

2

u/fykup 6h ago

Interesting insight, thanks! I was almost sold on GraalVM as an alternative for resource-constrained deployments. I wasn't particularly fond of the development experience, but the memory savings were impressive.

Helidon is definitely on my list, and I'm also considering adding Go as a non-Java baseline to the benchmark.

2

u/oweiler 6h ago

Project Leyden is no substitute for GraalVM.

1

u/_predator_ 3h ago

Almost doesn't matter when the industry decides native image is not worth investing in. Maybe someone else takes it over, or some vibecoder decides to continue evolving it.

2

u/arabian-tea 2h ago

GraalVM native image, or JIT?

1

u/fykup 7h ago

The idea is to keep the standard benchmark runs on conventional HotSpot without AOT, with additional flavors for optimizations such as GraalVM Native Image where supported.

For now, my earlier comparison includes Native Image results and should give you some ballpark numbers:
https://pvrlabs.xyz/articles/five-java-stacks-512mb-vps.html

Regarding metrics, Spring Boot has Actuator and Micrometer enabled (so do other frameworks), but the metrics endpoints aren't being scraped during the benchmark. There is still some instrumentation and memory overhead, but no external metrics collector or data pushing.

I'm very conscious of monitoring overhead on small servers. In fact, one of the motivations behind my experiments is that running Prometheus and Grafana alongside an application on a memory-constrained VPS is often impractical.

1

u/nekokattt 5h ago

there are lots of things you can do to reduce spring boot's footprint though.

I'm running a Discord bot using Spring Boot 4.2 + Spring Boot JDBC + Spring Web (for RestClient), but ditched autoconfigure and actuator (as they are the main contributors to slow starts and ballooning memory footprint). Project has over 150 classes in it and about 20,000 lines of code. Non-heap sits at 100MB and heap sits at 20MB

1

u/mencretdimulut 1h ago

try to compare it with other programming language like golang or rust