Today I've been hammering away at trying to get our application context to load faster for our developers. The context takes about 12 seconds to load before the integration tests start or when in the application server. Needless to say, that 12 seconds gets frustrating if you try to restart your app server 100 times in the day or run integration tests 100 times in the day.
I've profiled what is taking so long and the answers were rather frustrating. Basically no one bean is taking a huge amount of time. The longest bean is our initialization of Hibernate, but it is only about 1.5 seconds of the 12 second load time, which I can live with. It seems the majority of the time is spent setting up our services and controllers. For example 40 dao x 50ms + 40 services x 100ms + 100 controllers x 50ms = 11seconds.
I'm thinking the beans are taking too long too load. We basically have a BaseService that has members for every Dao. We also have a BaseController that has members to every Service. Is that a bad strategy? Would it be better to have each service only have reference to the 2-3 Dao's it might use? Would it be better for the Controllers to have reference to the 1-2 services it might use? Would that make the application context load faster?
Would it be faster if we had a DaoContainer in the base class instead so services had to call doaContainer.getUserDao().findUser( 1 )... That would be a "smell" as far as design goes in my opinion, but it would shrink the number of beans Spring has to resolve and theoretically should speed things up a bit.
Any tips? Isn't 12 seconds a fairly long time to initialize?


Reply With Quote
