Microservices in Java — A Second Look
Elliot Forbes

Hey Eliot -

You might find this article helpful:

but I think the TLDR for you is that most of the 1GB you mention gets eaten by tomcat default settings (200 threads IIRC) and JVM defaults, Boot’s impact is mostly on


You certainly can tune it down, and if you’re writing microservices that have a narrow purpose, that should be possible.

Want to save some space? Shrink the `ReservedCodeCacheSize`. The JIT won’t be able to create as much code, so your app will run slower (there are blog posts that describe a pretty significant drop off), but it’ll be smaller (traditional space vs. time tradeoff). Want to save some more space? Shrink the number of threads your Tomcat will start. Sure you’ll serve fewer concurrent requests per instance, but each instance will occupy less memory. Maybe you start to think about going for Reactor which will only start 4 threads (well, one per CPU core) and uses NIO to be more efficient. Want to save even more space? Shrink the default stack size. This is typically OK, since even Spring doesn’t create 1M stacks.

So as you see, you can *absolutely* configure a small JVM, but **the JVMs defaults** trade space for time generally. The JVM was designed from day one to work in environments where there was a ton of memory available, and so its defaults are turned to consume as much space as possible in order to eek out the best performance.