Muhammed Senussi
Muhammed Senussi
  • Muhammed Senussi
Where Spring Boot Startup Time Actually GoesJava

Startup time matters more than it used to. Autoscaling, spot instances and scale-to-zero all turn a slow boot into a user-visible latency.

Measure before you tune

Spring publishes startup steps as an ApplicationStartup recording. Point it at a FlightRecorder and you get a tree with timings instead of a guess. Every time I have done this the answer was different from the folklore.

The most expensive bean is usually the one that talks to something outside the process.

What tends to help

  • Lazy initialisation for the beans that are genuinely only used by one endpoint.
  • Explicit component scanning paths instead of scanning a whole parent package.
  • Deferring connection-pool warm-up past the readiness probe, not before it.

We took one service from 41 to 12 seconds without touching a single line of business logic.

1 Comments

  • Lotte Jansen

    June 20, 2024

    The readiness probe ordering caught us too. We were warming the pool before the probe and wondering why rollouts took so long.

Leave a comment