Boost Your Spring Boot Startup Speed with Spring Startup Analyzer
Spring Startup Analyzer is an open-source tool that captures Spring Boot startup data, generates interactive reports, and offers async bean initialization to speed up launches, with detailed statistics, bean timelines, method call metrics, unused JAR detection, and flame-graph visualizations, plus step-by-step usage instructions.
Spring Startup Analyzer is an open-source tool that analyzes the Spring application startup process, collects data, and generates an interactive report to help users identify slow startup points.
Analysis capabilities
The tool provides a sample HTML report that demonstrates its analysis features. The report includes six main sections:
Startup statistics such as total startup time, bean count, used/total JAR count, unused/total JAR count, and ClassLoader count.
Spring Bean initialization data, showing each bean's initialization time and details.
Bean initialization timeline, visualizing the order and duration of bean initialization during startup.
Method call details, including call time, total cost, and average time per invocation.
Clicking further reveals per‑call time costs and additional details.
Unused JARs after startup, helping to clean unnecessary dependencies.
Thread flame graph of the application startup process.
How to use
Follow these steps to analyze your own Spring Boot application:
Step 1: Download the latest release from the project's GitHub tags page.
Step 2: Unzip the package and note the extraction path.
Step 3: Edit Spring Boot startup parameters:
Add the Java agent parameter:
-javaagent:$HOME/spring-startup-analyzer/lib/spring-profiler-agent.jar(replace $HOME with your extraction path).
Configure analyzer options, e.g., set a 30‑minute timeout: -Dspring-startup-analyzer.app.health.check.timeout=30. Other configurable items are listed in the documentation.
Step 4: View logs in $HOME/spring-startup-analyzer/logs. Log files include:
startup.log – logs during the startup process.
transform.log – information about re‑transformed classes and methods.
Startup optimization
The project also provides a tool for asynchronous Bean initialization, which can significantly reduce startup time.
Step 1: Add the dependency:
<dependency>
<groupId>io.github.linyimin0812</groupId>
<artifactId>spring-async-bean-starter</artifactId>
<version>2.0.2</version>
</dependency>Step 2: Configure parameters:
# Async beans may appear at the end of the initialization order, affecting effectiveness; enable priority loading
spring-startup-analyzer.boost.spring.async.bean-priority-load-enable=true
# Specify async bean names
spring-startup-analyzer.boost.spring.async.bean-names=testBean,testComponent
# Core thread pool size for async initialization
spring-startup-analyzer.boost.spring.async.init-bean-thread-pool-core-size=8
# Max thread pool size for async initialization
spring-startup-analyzer.boost.spring.async.init-bean-thread-pool-max-size=8Step 3: Verify async initialization by checking $HOME/spring-startup-analyzer/logs/startup.log for entries like:
async-init-bean, beanName: ${beanName}, async init method: ${initMethodName}Note that async initialization is not a universal solution; consider the following:
First, optimize long‑initializing beans at the code level.
For third‑party beans that cannot be optimized, consider async.
Beans that are not depended on can be safely made async; use root‑bean analysis to identify them.
Be cautious with beans that have dependents, as async may cause issues during startup.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
