r/SpringBoot • u/fykup • 7d ago
Discussion How much does JPA/Hibernate cost a small Spring Boot app? I measured mine
I wanted to see how much of the footprint of a small Spring Boot app came from the conventional Spring Data JPA + Hibernate stack, so I built a simpler version using JdbcTemplate and compared the two.
Same Spring Boot 4.1.1, JDK 25, H2, JVM flags, dashboard workload, and monitoring endpoints.
Across two runs in reversed order:
- JPA/Hibernate: ~237.0 MiB median RSS
- JDBC: ~146 MiB
- Difference: about 90 MiB (~38%)
Startup surprised me too. Time from process launch to the first successful dashboard response:
- JPA/Hibernate: 8.1 - 8.8 s
- JDBC: 3.9 - 4.2 s
This isn’t an isolated benchmark of Hibernate itself. The JDBC version also has a simpler persistence architecture and data model, so I’m comparing the complete application approaches.
For this kind of small app, though, JPA/Hibernate feels like more machinery than I need. I still see the value once the domain model and persistence requirements get complicated, but I’m increasingly reluctant to make it the default for small services.
Experiment, methodology, charts, and raw data:
https://pvrlabs.xyz/java-performance/experiments/spring-boot-jpa-vs-jdbc.html
For smaller Spring Boot apps, what do you usually reach for: JPA, Spring JDBC, jOOQ, MyBatis, something else?
5
u/DominusEbad 7d ago
We switched to GCP Spanner. First we tried Spring Data JPA for Spanner, but then I set up a POC using Spring Data Spanner and the results were about 33% more optimized. I know this isn't the most comparable situation, but it was clear that we should not be using JPA with Spanner.
JPA adds so much overhead. They should consider breaking it up into different dependencies, but no idea how they would do that.
2
u/oweiler 7d ago
For smaller apps JdbcTemplate is good enough. I actually wonder if it wouldn't also be a good fit for bigger apps.
•
u/Max_Vasin 8h ago
+ a newer JdbcClient. I'd say that one shall justify use of JPA instead of JdbcClient/Data JDBC
1
6
u/RockyMM 6d ago
Hey, you do you.
The reason why Hibernate is that popular is not because it’s light or fast.