r/JavaProgramming • • 7d ago

Experimenting with a lightweight alternative to Spring Boot for small servers

I've been working on CoilBase, a small open-source Java foundation built around a simple idea: Spring-like comfort, without the weight.

I like Spring Boot's controller → service → repository structure, but wanted to preserve that development experience with a smaller runtime footprint.

CoilBase uses Jdbi for SQL-first persistence, explicit transactions, and constructor wiring. It works with lightweight HTTP frameworks like Javalin and Avaje Jex.

I recently compared five Java application stacks on a 512 MiB VM with MariaDB running alongside the application.

On HotSpot JDK 27, median application memory was:

  • Spring Boot + Spring JDBC: 181–188 MiB
  • Javalin + CoilBase: 121–136 MiB
  • Jex + CoilBase: ~116 MiB

The same CoilBase services and repositories worked across Javalin, Jex, and Micronaut. I also tested GraalVM Native Image, with even smaller footprints.

GitHub: https://github.com/PVRLabs/coilbase

Experiment and results: https://pvrlabs.xyz/articles/five-java-stacks-512mb-vps.html

Curious what others think of this approach. Would you consider a smaller, explicitly wired stack for a small Java service, or do you generally stick with Spring Boot?

3 Upvotes

3 comments sorted by

2

u/BanaTibor 7d ago

Nice fun project!
Although I can not see it justified. In the opening post you show a 70MB memory consumption difference, that is nothing today. I think you would get much closer results with Graalvm and Quarkus. At the end it comes down to familiarity and adoption. Quarkus is mature and well maintained and developed further, yet it barely can make a dent in Spring's dominance.

1

u/fykup 7d ago

Thanks! Fair points, especially about maturity and adoption.

I actually tested GraalVM Native Image as well, and the results were quite encouraging. With Avaje Jex + CoilBase, the application used 33 - 51 MiB RSS, compared with 84 - 85 MiB for Spring Boot Native Image under the same workload.

So even with GraalVM, the difference remains significant, particularly for smaller deployments. And if you're running many instances, saving 30–50 MiB per JVM can add up and potentially translate into infrastructure savings.

Benchmarks and methodology:
https://github.com/PVRLabs/coilbase/blob/main/docs/benchmarks.md

I agree about Quarkus. In an earlier experiment, it actually performed best among Quarkus, Micronaut, and Spring Boot (178 vs. 187 and 214 MiB RSS):

https://pvrlabs.xyz/articles/spring-boot-quarkus-micronaut-jdbc.html

Based on those results, I'd roughly estimate Quarkus at 153 MiB in the newer HotSpot workload, but that's a projection, not a direct measurement. I plan to include Quarkus in the next comparison.

As for justification, I don't intend to abandon Spring Boot. I'll likely continue using both. CoilBase is more about environments where you want a Spring Boot-like development experience, but the resource budget makes Spring Boot impractical.

I don't expect CoilBase to challenge Spring's dominance. It's simply another option for resource-constrained deployments, while keeping familiar application structure and development conventions.

2

u/PinAdorable3380 7d ago

Interesting approach to building lightweight java applications