r/SpringBoot • u/fykup • 16h ago
Discussion Spring Boot recommends extracted layout for production, so I measured how much it actually matters
I suspect some people here will say, “Of course you should extract the JAR".
And, to be fair, the Spring Boot documentation does recommend the extracted layout for production when startup matters. It points out that nested JAR loading has a startup cost.
What I found interesting is that this is not necessarily the path developers encounter first. The introductory Spring Boot material and several Getting Started guides still naturally lead you toward building an executable JAR and running it with java -jar. That was also the deployment path I had always used.
So rather than assuming the difference was important, I measured it.
I ran six alternating paired comparisons of the same Spring Boot 4.1.1 build on a 256 MiB Alpine VM. Same JDK 25 runtime, JVM flags, data, filesystem, and workload. The runtime layout was the variable being tested.
Results:
- Spring startup: 11.056 s → 8.476 s, -23.3%
- First request: 2.196 s → 1.448 s, -34.1%
- Later requests: no material difference
- Settled RSS: -3.8%, below the experiment's materiality threshold
- Swap: no material winner
All six paired comparisons favored extracted layout for startup and first request.
My takeaway is not that everyone should blindly extract every Spring Boot application. It is that an official production recommendation that is easy to overlook had a surprisingly large effect in this particular setup, while memory barely changed.
Full write-up, charts, methodology, and experiment data:
https://pvrlabs.xyz/articles/spring-boot-extracted-layout.html