Parallelize Component Scanning to Improve Spring Startup Time [SPR-9887] #14520
As my application is growing in size spring start-up time is increasing and starting to be quite annoying during development. The application is setup to use component scanning, and JPA so there are a lot of
628 classes in the application
279 beans with class level annotations
489 beans with field and method declaration annotations
None of the
This application takes about 20 seconds to launch on high End Late 2011 MacBook Pro 2.5 GHz core i7 8GB RAM 256GB SSD running Java 7u9 and tomcat 7.0.29 on a machine that is a couple of years old with a mechanical drive or a slower cpu the startup time becomes a slow 90 to 180 seconds.
Here are the times to start-up the various parts of the applications, as seen in a typical run of the application from within STS 3.1.
total spring contexts initialization time 12734 ms out of 17342 ms reported by tomcat for application startup time or 73% of startup time
For the WebApplication context here are the main times of the non spring bits computed by looking at timestamp data in the log file
total 5342 ms for aspectj + flway + hibernate to do the initialization of the application context
Spring Web Context + Dispatches Servlets accounts for 7068 ms or 40% of total startup time
I have not taken a profiler to find out where that time is spent, my guess is that scanning of the classpath is a major part of this process, It would be great if spring can do the component scanning using multiple threads, to speed up the startup process.
20 seconds might seem pretty fast for a Java app but every week as code gets added that 20 seconds goes up. Also no complied stacks like nodeJS, and others really have very little startup time, I think Spring has always been the standard bearer in the java world for developer productivity, parallelizing startup will make a big difference for developers working on large application.
Affects: 3.1 GA
6 votes, 13 watchers
The text was updated successfully, but these errors were encountered: