I'm currently running Spring Boot APIs that are consuming around 300 MB of RAM per pod, even for the simplest testing versions with minimal dependencies. I'm already using lightweight JRE base images instead of the full JDK. I'm curious if switching to native compilation with Spring Boot 3+ could help lower the RAM usage per pod. Is this level of memory consumption normal for Spring Boot applications?
4 Answers
Yep, my super basic Spring Boot app uses about 250-280 MB on the JVM, and with native compilation, it gets down to about 100 MB. However, I find that a similar pure Java application could run on just 10 MB. It does seem high, but it’s often the trade-off for using frameworks like Spring. You might want to consider the overall design of your application and whether you need all that Spring functionality, or if a lighter framework would suffice.
It sounds like you're on the right track! Generally, 300 MB for a basic Spring Boot app running on the JVM isn't too surprising, especially considering that’s how Spring operates. If you go for native compilation, I've heard folks report memory usage dropping to around 100 MB, which is a significant improvement. Just be prepared that while Spring offers great convenience, it often comes with a bit of overhead.
If you’re looking for alternatives to reduce your memory footprint, Quarkus is a great option! It’s designed for cloud-native Java applications and might offer better resource utilization than Spring.
Have you checked your pod resource limits/requests? The JVM uses memory for things beyond just the heap, like CPU connections and other memory requirements. Setting these values can help the JVM manage memory usage better. You might find that what you're seeing isn't unusual at all.
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String