When developing my SpringBoot application, I didn't cared at all about the startup time
Indeed, on my workstation, my application took around 3 and 4 seconds to start, which is, for my project needs, perfectly acceptable
However, I realized recently that, on particular environments, my application takes around 20 seconds to start... far less acceptable.
More problematic, on Docker/Kubernetes, it can take more that one minute to start: in that case, my application can be concidered as being dead before even being up!!!
In order to investigate this issues, I put in place the actuator/startup
endpoint, as detailed at the following URL: https://www.amitph.com/spring-boot-startup-monitoring/
Then, on the host where my application takes 20 seconds to start, I queried this endpoint and I found:
{
"startupStep": {
"name": "spring.context.refresh",
"id": 5,
"parentId": 0,
"tags": []
},
"startTime": "2021-12-13T08:41:16.826503258Z",
"endTime": "2021-12-13T08:41:31.840217619Z",
"duration": "PT15.013714361S"
},
**it appears that the step spring.context.refresh
takes more than 15 seconds!!!
Any idea about
- what does this step
- why is it so slow
- how can investigate deeper
Thanks for all
Philippe