Menu

Spring Boot in a 512 MB container: JVM flags, a layered image, and honest start-up numbers

DEV Community: java·SnapDeploy·1 day ago
#wa9bTwlh
#devtojava#devto#dev#boot#container
Reading 0:00
15s threshold

TL;DR: By default the JVM takes only a quarter of a container's memory limit for the heap, and a small Boot app can take half a minute to start on a quarter of a CPU. Telling the JVM how much it may use, trimming what Boot starts, and building a layered image on Java 21 fixes most of it. Measured start-up figures, database connection sizing, health checks and the three log failures we see most, tested on our own Spring Boot app.

Spring Boot has a reputation for being heavy, and on a 512 MB container with a quarter of a CPU the reputation is partly earned: with default settings a small Boot app can take half a minute to start and hold more memory than it needs. SnapDeploy itself is a Spring Boot application, so this is not theory.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.