Spring Boot Slow Startup Time in Docker when limiting CPUs
See original GitHub issueMy organization is wanting to optimize the usage of our applications within a Kubernetes container by utilizing the minimum appropriate CPU for the applications running. When doing analysis, we have discovered a healthy area that the CPU allows the application to run appropriately. However the startup time for the application takes a huge hit in our environment.
Suggesting to increase CPU strictly for startup time enhancements really isn’t an option we want to pursue and looking through the documents and guides we could find, there doesn’t appear to be a lot of information on appropriate ways to address this problem effectively.
I would like to throw an issue up to analyze the use case of an application when restricting CPU. I have created a repo that has a bare bones Spring Boot application that we can analyze for this discussion.
We are interested in trying to create a standard document on how our developers can utilize Spring Boot effectively in Kubernetes with as thin of a CPU as possible while still having the startup time performance we would expect an application to have.
Currently we are running using the cpu setting of 600m within Kubernetes which is roughly equivalent to running the docker command with --cpus=".6".
Running on my box which is an i7-7600U @ 2.8GHz with 16 GB of RAM, I am seeing roughly 30 seconds startup time with the code in my repository.
A member of our org has also created some benchmark results comparing other frameworks with similar code. Their box they ran the tests on was an i7 process @ 2.6 with 16 GB of RAM as well. The results are available here.
I would like to start a conversation that will hopefully lead to some focused documentation on this particular request. I believe this documentation could help many organizations using Spring Boot that is starting to migrate to Kubernetes. I’m not sure if it would help to also bring in the Spring Cloud Kubernetes team potentially as well but let this be the start of the discussion.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:13 (5 by maintainers)
Top Related StackOverflow Question
Thanks for the update.
Probably could get you 10 or 20% improvement for simple apps.
Not really going to help, unless you end up with fewer features (see above).
Not sure what you mean here. The dependencies are the dependencies. You either use them or you don’t - it has nothing to do with the JAR layout.
Both will have an impact (Graal Native a big impact). Both are limited in scope, and are still experimental. But please do play around and see if it works for you. Feedback more than welcome.
The database connection of implementation won’t make any difference. For JPA you need the additional spring data lazy flag, i.e.
spring.data.jpa.repositories.bootstrap-mode=lazy.