Spring Boot app takes 40 seconds to start — how to find what's slow?
poze a month ago114 gadeen
Our Spring Boot service's startup has crept up to 40s, which hurts deploys and autoscaling. How do I profile startup?
Dyagnostik IA
Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.
1 Repons
1. Startup actuator endpoint: record bean initialization times:
SpringApplication app = new SpringApplication(App.class);
app.setApplicationStartup(new BufferingApplicationStartup(2048));
app.run(args);
Then GET /actuator/startup lists the slowest steps.
2. Common culprits: Hibernate ddl-auto=update or validation on a big schema, classpath scanning over huge packages, eager connections to slow external services, and Flyway migrations.
3. Quick wins: - spring.main.lazy-initialization=true (test it carefully). - spring.jpa.open-in-view=false, and set ddl-auto to none in production. - Run on Java 21+ with Class Data Sharing (AppCDS). For the biggest gain, consider GraalVM native image or CRaC (checkpoint/restore).
Konekte pou di lòt moun si li te mache.
Sign in and verify your email to post an answer.