Spring Boot on a 512 MB VPS: what actually fits?
I wanted to see how small I could make a realistic Spring Boot deployment while still keeping basic monitoring on the same VPS.
I first tried 256 MB RAM, but that wasn’t really viable for the representative app I tested. With 512 MB RAM + 256 MB swap, the application and lightweight monitoring completed the experiment successfully.

One thing that stood out was the gap between configured heap and actual JVM process memory. Even with a small -Xmx, RSS was substantially higher once you include metaspace, native allocations, threads, code cache, etc.
I wrote up the setup, JVM flags, measurements, and what failed at 256 MB:
https://pvrlabs.xyz/articles/spring-boot-512mb-vps.html
Curious how this compares with what others are seeing on small JVM deployments.
22
u/oweiler Aug 21 '26
19
u/Nymeriea Aug 21 '26
we have a whole tomcat with 10+ spring war deployed in prod. it handle 1000x request /hours with ease and only 250mb. it has datadog and everything.
I wonder why you need so much for a single spring app
9
u/GuyWithLag Aug 21 '26
Next up: JDK 25 w. compressed headers and Project Lilliput.
8
u/nekokattt Aug 21 '26
ive been running a spring boot discord bot on 256mb ram in a container. It isnt easy, but it is doable if you are pragmatic (e.g. do not use autoconfiguration, and utilise jdk 25 features for memory reduction).
5
u/aoeudhtns Aug 21 '26
I understand you're testing Spring Boot as it's what you're using now, but you can squeeze out more in low memory environments with other frameworks - Quarkus, and even more so, Micronaut. Probably Helidon too but I'm unsure. Whether that is useful information for you, I dunno. We have services in Spring Boot and probably aren't going to switch any time soon (if ever) as we're OK with what they're using/requiring to achieve the throughput we need (about 400 MiB, and we're getting thousands of tps). But if we do something new we'll probably trial Quarkus.
3
u/Lundasaur Aug 21 '26
Have you tried using native compilation?
3
u/user_of_the_week Aug 21 '26
Have you tried -XX:MaxRAM?
1
u/fykup Aug 25 '26
Follow-up: I pushed the same experiment down to 256 MiB VPS. With Alpine, JDK 25, an 80 MiB heap, C1-only compilation, a 32 MiB code cache, compact object headers, and 512 MiB swap, Spring Boot + StatLite completed the full one-hour run.
Still very much a stretch configuration, though: 184 MiB swap was in use and there was one Hikari housekeeper delay.
New write-up: https://www.reddit.com/r/java/s/FnsEQKQKyJ
3
u/holyknight00 Aug 21 '26
spring + spring boot is super heavy by default; i would try other java frameworks that are more lightweight. In these kind of environments, I would stay as close as raw java as possible or even give up on java altogether if more throughput is required.
0
u/kimec Aug 21 '26
Or just use OpenJ9 and cut the memory usage in half including heap, codecache and metaspace... It's literally five lines of xml if building SB images via SB plugin
0
u/Individual-Praline20 Aug 21 '26
Errrr give it 4Gb. Problem solved.
-3
u/darknebula Aug 21 '26
Are you using Webflux? That can operate in RAM limited situations much better than normal Spring Boot