Reputation: 897
I just recently upgraded one of my teams Spring Boot applications from 2.1.3-RELEASE to now be 2.3.0-RELEASE, well as upgrading Hibernate versions from 5.3.6.Final to be 5.4.15.Final.
Everything went fine, however now when the application starts on the server, it takes anywhere from 800-900 seconds to start (roughly 15 minutes) when it used to only take about 30 seconds.
Something important to note, when running on localhost, with both 2.1.3 and 2.3.0, application startup was the same, about 12-15 seconds.
The slow startup issue is only encountered when deployed to the server.
I am certain the issue lies with the new version of Spring Boot, as i switched to SpringBoot 2.1.3 and left Hibernate as 5.4.15, and the startup was fast.
So, is there something that has changed in recent SpringBoot releases where I have to set a property to disable certain checks or something?
Most articles and posts I have seen said the issue was with Hibernate and to set this property spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
but i did that and it had no effect.
UPDATE:
I tried the property spring.main.lazy-initialization=true
but it had no effect on startup performance.
UPDATE 2:
I downgraded from 2.3.0 to 2.2.7 which resulted in an average of 170 second startup time, vs an average of 800 second startup times with 2.3.0. A roughly 3 minute startup time is still terrible, but, with a difference of 12 minutes with no change other than versions, I wonder if its just too ambitious to be on the latest version of Spring Boot.
Still very curious if anyone has some suggestions of why we would have gone from a 30 second start time with 2.1.3 to a 3 minute start time with 2.2.7.
Was there a major changed introduced between 2.1.x and 2.2.x?
LAST UPDATE
I tried version 2.2.5 which resulted in no decrease in startup performance from 2.1.3. If anything startup performance has increased. So, this leads me to believe something has changed under the hood with versions 2.2.6 and higher.
I am going to stick with 2.2.5, but am still hoping for an answer if anyone out there has attempted to use these most recent versions of Spring Boot.
Upvotes: 9
Views: 6258
Reputation: 606
If you can go up to Spring Boot 2.4.x there is a new Actuator endpoint called /startup which will tell you how long each initializing bean took, which should tell you what is so slow: https://medium.com/techwasti/startup-actuator-endpoint-spring-boot-54a8dd0a1fdb
Upvotes: 1
Reputation: 69
A part of my job is patching multiple spring boot applications. I didn't expiernce slower bootups in general, but 1 Project which used hibernate search and spring boot data, had seriouse issues with lazy initialisation which lead eventualy to thread deadlocks.
https://github.com/spring-projects/spring-framework/issues/25111
Another thing to keep in mind is the "new" spring boot docker image builder :) https://spring.io/blog/2020/01/27/creating-docker-images-with-spring-boot-2-3-0-m1
Upvotes: 0
Reputation: 43
I've hit the same issue trying to upgrade from spring boot 2.2.6 to 2.3.0. I observe slower application start time when running spring boot app on server or in docker container and don't see the problem with local runs both on win and mac.
Out of curiosity I took spring-petclinic and tried to run it docker. That's the start up times I get with it.
With Spring Boot 2.3.0
2020-05-29 15:33:28.957 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 22.723 seconds (JVM running for 24.397)
2020-05-29 15:41:08.278 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 22.955 seconds (JVM running for 24.641)
2020-05-29 15:42:20.741 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 24.847 seconds (JVM running for 26.534)
2020-05-29 15:43:28.472 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 24.645 seconds (JVM running for 26.294)
2020-05-29 15:43:58.152 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 23.931 seconds (JVM running for 25.609)
2020-05-29 15:44:30.186 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 24.708 seconds (JVM running for 26.608)
With Spring Boot 2.2.6
2020-05-29 15:40:25.829 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 19.062 seconds (JVM running for 20.474)
2020-05-29 15:41:35.797 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 18.18 seconds (JVM running for 19.582)
2020-05-29 15:48:36.693 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 18.648 seconds (JVM running for 20.067)
2020-05-29 15:49:00.379 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 18.548 seconds (JVM running for 19.978)
2020-05-29 15:49:23.282 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 18.808 seconds (JVM running for 20.218)
2020-05-29 15:49:47.100 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 19.862 seconds (JVM running for 21.285)
2020-05-29 15:50:08.247 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 16.599 seconds (JVM running for 17.916)
I wonder what has changed in that area...
Surprisingly spring boot 2.3.1 looks better, almost the same as 2.2.x:
2020-06-19 21:16:18.935 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 18.886 seconds (JVM running for 20.552)
2020-06-19 21:16:43.461 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 18.637 seconds (JVM running for 20.091)
2020-06-19 21:17:07.226 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 18.526 seconds (JVM running for 20.007)
2020-06-19 21:17:30.172 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 19.694 seconds (JVM running for 21.209)
2020-06-19 21:17:57.662 INFO 1 --- [ main] o.s.s.petclinic.PetClinicApplication : Started PetClinicApplication in 20.348 seconds (JVM running for 21.85)
I suggest to give 2.3.1 a try.
Upvotes: 0