I have an application that is getting fairly large, and the Spring start up time is about 20 seconds. For production use, this is fine, but for development, this is a big pain.
What is a good profiling tool or approach that can give me precisely the information I need to figure out what is taking so long? Maybe it's something I can optimize?
My application is a fairly typical spring/hibernate web app. There's about 50 database tables and several hundred beans (like 200-300... I didn't count). There's a few @Configurable beans. Lots of component scanning. I am also using Spring Security.
I did some primitize profiling with log4j - just at the INFO setting. Here are some of the things that are taking a bit of time:
There are a couple of things that take .5 to maybe 1 second at the most, but these 3 were the largest ones.
When a Spring Boot Application has slow startup, it can be one or more beans and related dependencies taking longer to initialise and slowing down the entire process. Profiling Spring Boot application doesn't often help in diagnosing the startup issues.
React + Spring Boot Microservices and Spring The Spring container is at the core of the Spring Framework. The container will create the objects, wire them together, configure them, and manage their complete life cycle from creation till destruction.
Spring IoC Container is the core of Spring Framework. It creates the objects, configures and assembles their dependencies, manages their entire life cycle. The Container uses Dependency Injection(DI) to manage the components that make up the application.
One option you can try is to use the default-lazy-init option to lazily initialize the beans. Spring initializes all singleton scoped beans during initialization. Read Lazily-instantiated beans section of the reference doc.
Make sure to parameterize the value so that you can change it to true during dev time and false during production deployment.
Component scanning is Slow. Refer to this post on how to disable this when you use Autowiring.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With