Speed Up Spring Boot Startup with Actuator’s Startup Endpoint

This article explains how to use Spring Boot 2.4's actuator startup endpoint to monitor and analyze application initialization time, offering practical steps, configuration examples, code snippets, and a test case to identify and optimize slow components such as database pools and custom beans.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
Speed Up Spring Boot Startup with Actuator’s Startup Endpoint

Background

As a Spring Boot project adds more middleware, its startup time gradually increases. The author notes that many non‑official starters do not disable the default proxyBeanMethods attribute of @Configuration, which can hurt performance. Serial initialization logic, such as an inefficient Druid datasource pool, also slows startup.

Spring Boot 2.4 provides a startup monitoring endpoint that lets developers observe each component’s initialization time, which is far more precise than parsing raw startup logs.

Getting Started

Add the actuator dependency:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Expose the startup endpoint:

management:
  endpoints:
    web:
      exposure:
        include: startup

Configure the main class to use a buffering startup recorder (increase the buffer size if many beans are present):

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        // Enable buffering only during development or troubleshooting
        new SpringApplicationBuilder(DemoApplication.class)
            .applicationStartup(new BufferingApplicationStartup(20480))
            .run(args);
    }
}

Query the endpoint (POST) to obtain the JSON report:

curl -XPOST http://localhost:8080/actuator/startup
{
  "springBootVersion":"2.4.0",
  "timeline":{
    "startTime":"2020-12-04T01:38:15.028114Z",
    "events":[
      {
        "startupStep":{
          "name":"spring.event.invoke-listener",
          "id":296,
          "parentId":0,
          "tags":[
            {"key":"event","value":"ServletRequestHandledEvent: url=[/actuator/startup]; client=[0:0:0:0:0:0:0:1]; method=[POST]; servlet=[dispatcherServlet]; session=[null]; user=[null]; time=[83ms]; status=[OK]"},
            {"key":"listener","value":"org.springframework.boot.context.config.DelegatingApplicationListener@2053d869"}
          ]
        },
        "startTime":"2020-12-04T01:38:28.402870279Z",
        "endTime":"2020-12-04T01:38:28.402929390Z",
        "duration":"PT0.000059111S"
      }
    ]
  }
}

Test Case

Create a bean that deliberately delays initialization to see its impact:

@Configuration(proxyBeanMethods = false)
public class DemoConfiguration {
    @Bean
    public RestTemplate restTemplate() throws InterruptedException {
        // Simulate a costly initialization step
        Thread.sleep(5000);
        return new RestTemplate();
    }
}

After starting the application, request /actuator/startup and verify that the RestTemplate bean appears with a ~5‑second duration.

Sorting by Duration

The endpoint returns events in startup order. To sort them by elapsed time, export the JSON and use an online tool such as bejson.com .

Select the option to sort by duration to quickly identify the slowest initialization steps.

References

Spring Boot 2.4 release notes: https://www.oschina.net/news/120443/spring-boot-2-4-0-released

Druid connection‑pool issue: https://github.com/alibaba/druid/issues/1368

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.

performancespring-bootstartup-monitoring
Java Architecture Diary
Written by

Java Architecture Diary

Committed to sharing original, high‑quality technical articles; no fluff or promotional content.

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.