How to Speed Up Spring Boot Startup: 16 Proven Optimizations

This article walks through a series of practical experiments—ranging from baseline Flux tests to lazy initialization, JVM options, dependency exclusions, and AppCDS—to dramatically reduce Spring Boot application startup time, ultimately achieving sub‑second launch speeds.

Programmer DD
Programmer DD
Programmer DD
How to Speed Up Spring Boot Startup: 16 Proven Optimizations

The author investigates the question "How fast is Spring?" after watching the 2018 Spring One Platform talk, and documents a step‑by‑step series of benchmarks and configuration tweaks aimed at speeding up Spring Boot startup.

1. Flux Baseline

A minimal Reactive Web project is created with @SpringBootApplication and a simple controller returning "Hello". Using OpenJDK 11 the benchmark shows a startup time of 2.938 ± 0.287 s/op .

2. WebMVC

The same application is built with Spring MVC (Tomcat) instead of WebFlux (Netty). The benchmark records 3.281 ± 0.342 s/op , confirming that WebFlux starts slightly faster.

3. spring‑context‑indexer

Adding spring-context-indexer creates a primary key index. The startup time becomes 3.063 ± 0.102 s/op , a small regression.

4. Lazy Initialization

Enabling lazy bean initialization via a custom BeanFactoryPostProcessor reduces the time to 2.844 ± 0.129 s/op , a modest improvement.

5. No Verify

Running the JVM with -noverify yields 2.582 ± 0.060 s/op , slightly faster than the baseline.

6. TieredStopAtLevel

Setting -XX:TieredStopAtLevel=1 cuts the startup time to 1.980 ± 0.037 s/op , a significant gain.

7. Explicit Spring Config Location

Specifying -Dspring.config.location=classpath:/application.properties results in 3.026 ± 0.139 s/op , which is slower.

8. Disable JMX

Disabling JMX with -Dspring.jmx.enabled=false improves the time to 2.877 ± 0.097 s/op .

9. Exclude Logback

Removing Logback from the classpath yields 2.904 ± 0.096 s/op , a slight improvement.

10. Exclude Jackson

Excluding the Jackson JSON starter reduces the time to 2.789 ± 0.093 s/op .

11. Exclude HibernateValidator

Removing Hibernate Validator brings the startup down to 2.857 ± 0.084 s/op .

12. AppCDS

Enabling Application Class Data Sharing (AppCDS) on OpenJDK 10‑11 does not noticeably improve the baseline ( 2.957 ± 0.079 s/op ) because the Fat JAR packaging keeps most classes out of the shared archive.

13. Flux with Thin Launcher

Using the Spring Boot Thin Launcher (exploded layout) reduces the startup to 2.476 ± 0.091 s/op .

14. Thin Launcher + CDS

Combining the Thin Launcher with AppCDS yields a dramatic improvement: 1.535 ± 0.036 s/op .

15. All Applied

Applying every optimization together (Flux baseline, lazy init, no‑verify, TieredStopAtLevel, disabled JMX, excluded Logback, Jackson, HibernateValidator, Thin Launcher, and AppCDS) achieves a startup time of 0.801 ± 0.037 s/op , i.e., less than one second.

16. Additional Thoughts

The author notes a mention of "Functional Bean Definitions" from a recent conference, suggesting further speed gains by using Spring without Spring Boot.

17. Result List

Benchmark Mode Cnt Score   Error Units
MyBenchmark.case01_FluxBaseline                10 2.938 ±0.287 s/op
MyBenchmark.case02_Web                         10 3.281 ±0.342 s/op
MyBenchmark.case03_WithContextIndexer          10 3.063 ±0.102 s/op
MyBenchmark.case04_WithLazyInit                10 2.844 ±0.129 s/op
MyBenchmark.case05_WithNoVerifyOption          10 2.582 ±0.060 s/op
MyBenchmark.case06_WithTieredStopAtLevel1Option10 1.980 ±0.037 s/op
MyBenchmark.case07_WithSpringConfigLocationOption10 3.026 ±0.139 s/op
MyBenchmark.case08_WithJmxDisabledOption       10 2.877 ±0.097 s/op
MyBenchmark.case09_WithoutLogback              10 2.904 ±0.096 s/op
MyBenchmark.case10_WithoutJackson              10 2.789 ±0.093 s/op
MyBenchmark.case11_WithoutHibernateValidator   10 2.857 ±0.084 s/op
MyBenchmark.case12_WithAppCds                  10 2.957 ±0.079 s/op
MyBenchmark.case13_Exploded                     10 2.476 ±0.091 s/op
MyBenchmark.case14_ExplodedWithAppCds          10 1.535 ±0.036 s/op
MyBenchmark.case15_AllApplied                  10 0.801 ±0.037 s/op
Original article: https://dev.to/bufferings/lets-make-springboot-app-start-faster-k9m Author: Mitz Translator: Lensen
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaoptimizationSpring BootBenchmarkStartup Performance
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.