r/java • • 3d 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.

55 Upvotes

39 comments sorted by

14

u/Svellere 3d ago

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

2

u/fykup 3d ago edited 3d 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.

Updated chart: https://github.com/PVRLabs/framework-benchmarks/blob/main/docs/featured-v1.svg

6

u/mands 3d ago

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

5

u/fykup 3d ago

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

3

u/rbygrave 3d ago

Given you are using avaje-jex note there is avaje-nima which is for Helidon 4.x, if you are using avaje-http to code gen the controller adapter code then you can pretty easily swap to avaje-nima [but I haven't looked at the benchmark code so I suspect its not doing that]

3

u/fykup 3d ago

I'm a big fan of the Avaje stack and the lightweight approach behind Jex. I use Avaje HTTP in my apps, including the Jex benchmark, to generate the controller adapters..

For Helidon, I'll probably follow the same approach as with Micronaut: an idiomatic implementation using its own HTTP framework and JDBC abstraction, without Jdbi, Avaje Jex or Avaje HTTP.

I'd like to first see how Helidon compares to the existing stacks, and then potentially explore an avaje-nima variant. Thanks for the pointer!

1

u/Distinct_Meringue_76 3d ago

I don't think helidon will fare well in a benchmark optimized for throughput.

1

u/fykup 3d ago

I'm really curious to see the results. I haven't explored Helidon yet, so I genuinely don't know what to expect. Several people have mentioned it, so I'll definitely give it a try!

1

u/fykup 3d 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 3d ago

I would recommend Helidon 27 with Doma.

5

u/TheKingOfSentries 3d 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?

7

u/fykup 3d 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.

1

u/perryplatt 3d ago

Wouldn't avaje with Nima be a better comparison?

2

u/fykup 3d ago

Sorry, I had Helidon on my mind and initially interpreted your suggestion as a question about how I'd implement the Helidon app.

My primary focus is efficient hosting on small VPSs rather than maximum HTTP throughput. I'm interested in applications serving hundreds or thousands of requests per minute with low resource consumption, good response times and room to grow. Jex has been an excellent fit for that use case so far, but I'd be curious to see how Avaje Nima compares.

1

u/fykup 3d ago

For isolating the differences between HTTP servers, yes. But I'd like to see how an idiomatic Helidon application performs first.

Imagine someone familiar with Helidon but unfamiliar with Avaje looking at the benchmark. They might reasonably question why I didn't use Helidon's own APIs.

I took a similar approach with Quarkus, keeping external dependencies to a minimum. I used Jdbi because Quarkus doesn't offer an equivalent to Spring JDBC out of the box.

I think Avaje Nima would make a great follow-up experiment, answering a slightly different question.

2

u/jonenst 3d ago edited 2d 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 -XX: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 3d 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/fykup 3d ago

Quick update: custom JVM settings are now supported, both locally and through GitHub Actions.

I tested all four of your suggested flags in my fork. Here's the completed benchmark run.

Peak application RSS under sustained load:

StackPublished local runCustom CI run
Jex + Jdbi148-150 MiB136-137 MiB
Quarkus + Jdbi200-205 MiB159-171 MiB
Spring Boot222-233 MiB209-214 MiB
Micronaut210-219 MiB177-189 MiB

All four stacks completed both rounds at 40 RPS without errors, with sustained p99 latency between 3.6 and 7.2 ms in CI.

The published baseline was measured locally on dedicated hardware, while the custom run used a GitHub-hosted runner. These results are not directly comparable, and we cannot attribute the lower RSS to the JVM flags. We can compare the stacks within the custom run, but isolating the effect of the flags requires a controlled baseline and variant on the same hardware.

You can now fork the repository, edit config-v1.json directly on GitHub, and run the benchmark without any local setup. The full report, charts, and raw evidence are available in the workflow artifacts.

Custom runs guide

2

u/jonenst 2d ago edited 2d ago

I played a bit with your benchmark (using h2, running the jar on one side, python workload/run.y on the other side. also the quote polled fixture), running the jar on a 2Ghz cpu with CPUQuota=5% (so only running 5ms every 100ms), I get a cpubound maximum of 30-50req/s depending on the concurrency sweet spot (you just have to be patient when starting it, it takes minutes !)

So aiming for 40req/s on a normal server is clearly not cpu bound. You should easily reach 500rps or even 1krps per core for throughput. in my observation the p99 latency at 500rps for 1 full core is still in milliseconds. At these levels it might make sense to use http keepalive as well if most requests come from the same clients (maybe a few clients, or a load-balancer/reverse-proxy in front of the springboot server)

I also saw that with 16 tomcat threads you can reduce xmx to Xmx45 without having any full gc during a load test that is saturating the tomcat threads (in flight request in tomcat threads always 16 (not the os/tomcat accept queue before them)

Setting tomcat threads to 200 (and hikari to something like 50 to avoid hikari timeouts) and saturating 200 tomcat threads (same, in flight request in tomcat threads threads always 200), then you need xmx 80mb to handle the conccurency without full GCs

1

u/fykup 2d ago

Thanks for testing the boundaries! 40 RPS was actually a very approximate initial choice, so this is useful feedback.

I'm planning to test 100 RPS as a potential new default, assuming all four stacks can handle it comfortably with PostgreSQL sharing the same CPU and memory budget.

I'd also like to explore a throughput-oriented benchmark in a dedicated experimental branch, including HTTP keep-alive and different concurrency settings.

Your findings about the relationship between concurrency and minimum heap requirements are particularly interesting as well.

I've filed two GitHub issues to capture these investigation ideas, including your observations.

2

u/Paw565 3d ago

How did you pick xms and xmx? Did you try other values?

1

u/fykup 14h ago

I arrived at Xmx80m empirically through my earlier experiments. It works pretty well for applications of this size.

I recently compared Xmx70m and Xmx80m at 100 RPS, with two rounds per stack. All eight runs at 70m completed without errors, timeouts, dropped requests or OOM kills.

Here are the results (80m / 70m):

StackAvg. peak RSS (MiB)Avg. p99 (ms)Avg. total GC pause (ms)Longest GC pause (ms)
Jex153.4 / 149.19.42 / 9.13530 / 81110.88 / 13.46
Quarkus208.9 / 201.19.06 / 8.99111 / 19320.79 / 15.06
Spring Boot231.8 / 227.810.25 / 10.24427 / 50625.76 / 32.82
Micronaut218.2 / 210.28.86 / 9.2857 / 1654.38 / 16.08

GC statistics cover the 185-second sustained measurement windows. Averages are across the two rounds.

While 70m worked for all four stacks, the memory savings were relatively modest, cumulative GC pause time increased, and the longest observed GC pause increased for three of the four stacks.

So I decided to retain Xmx80m as a conservative balance between memory footprint, GC behavior and heap headroom. Two rounds per configuration aren't enough to establish long-term stability, though.

2

u/mencretdimulut 3d ago

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

1

u/fykup 3d ago

Will do! I'm planning to start with Go for the cross-language comparison, but Helidon is next on my list.

1

u/adventureloverishere 3d ago

Interested in comparison with go too

0

u/mencretdimulut 3d ago

im keen to see which part a Java framework would excel when being compared with golang or rust

1

u/LaM3a 2d ago

You can check the series of video by Arjay McCandless if you want a comparison of languages on the same small server : https://www.youtube.com/watch?v=sQXFhh_PiG4

3

u/nekokattt 3d 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/Unfair_Ad8967 3d 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.

3

u/Joram2 3d 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 :)

3

u/fykup 3d 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.

7

u/grashalm01 2d ago

GraalVM dev here. I am not aware of a Oracle strategy to move away from GraalVM.

I think quite the opposite is true. If you follow our work with the Crema and Ristretto projects you will see that we are working hard to close compatibility gaps in native image to also load bytecodes dynamically on top of it's existing AOT compilation. GraalVM will remain an AOT first runtime though.

I am conviced the future will be AOT first, but it remains to be seen whether the java team will build a whole program AOT feature. Leyden is still just a cache.

1

u/Joram2 3h ago

If you are a GraalVM dev, you should know much more than I do. However, this is what my Azul Enterprise support tells me.

Also, I'm quoting Oracle JDK VP here https://blogs.oracle.com/java/detaching-graalvm-from-the-java-ecosystem-train

The GraalVM team are transitioning to focus on non-Java Graal Languages including GraalPy and GraalJS. Details are expected to be announced later.

GraalVM Early Adopter technology, including Native Image, is being discontinued for Java SE Product customers. The goals of improving the startup time, time to peak performance, and footprint of Java programs are being pursued further in OpenJDK’s Project Leyden as a standard part of Java.

We encourage any customers using the Graal JIT to migrate to the Oracle JDK JIT.

When I asked ChatGPT it said, "GraalVM is not a dying project, but its ambition to become the next-generation general-purpose Java runtime has effectively been retired by Oracle. The future of mainstream Java runtime optimization is increasingly centered on HotSpot and Project Leyden."

5

u/oweiler 3d ago

Project Leyden is no substitute for GraalVM.

1

u/_predator_ 3d 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 3d ago

GraalVM native image, or JIT?

1

u/Joram2 3h ago

Both. From https://blogs.oracle.com/java/detaching-graalvm-from-the-java-ecosystem-train

GraalVM Early Adopter technology, including Native Image, is being discontinued for Java SE Product customers. The goals of improving the startup time, time to peak performance, and footprint of Java programs are being pursued further in OpenJDK’s Project Leyden as a standard part of Java

We encourage any customers using the Graal JIT to migrate to the Oracle JDK JIT.

1

u/fykup 3d 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.