2

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

Philippe MESMEUR
  • 737
  • 8
  • 22
  • That is the start of your application... So yes that will take almost all the time. Generally slow startup is due to database connectivitiy being slow or using Hibernate to manage (or validate) the schema, which can be terribly slow, especially when using a remote database (and using 2 docker containers even on the same machine is a remote database). – M. Deinum Dec 13 '21 at 09:15
  • Thanks for your answer. FYI, application does not use any database nor Hibernate. In fact, it uses almost nothing and does not connect to any servers at startup – Philippe MESMEUR Dec 13 '21 at 09:30
  • Well without knowing what your application does this will thus be impossible to answer. If it isn't a database or connection to the server it must be related to your docker container, like hostname lookups being slow etc. But without further information / details this will be impossible to answer. – M. Deinum Dec 13 '21 at 09:32
  • OK, I understand perfectly. The startup is not only slow on Docker, it is also slow on a test virtual machine. Once started, the application is not slow. What is hard to understand is that on my workstation, the startup is very fast... – Philippe MESMEUR Dec 13 '21 at 09:37
  • Could be entropy, see https://serverfault.com/questions/754153/java-application-is-slow-in-virtual-server-kvm and check if you pass the parameter (espeically in docker that might help). – M. Deinum Dec 13 '21 at 09:47

0 Answers0