Announcement Announcement Module
Collapse
No announcement yet.
Question about general architecture of base classes for services Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question about general architecture of base classes for services

    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?

  • #2
    Originally posted by whipshaw View Post
    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?
    Why are you doing that? Your code get bloated with tons of collaborators you don't even need. DI was made to avoid this kind of non sense. You're suppose to inject only the collaborators you need.

    I believe your application is going to load much faster once you clean out this mess because right now each service instance receives an instance of each DAOs (I hope they aren't prototypes...). No wonder why it is so slow.

    Comment


    • #3
      Originally posted by madtree View Post
      Why are you doing that? Your code get bloated with tons of collaborators you don't even need. DI was made to avoid this kind of non sense. You're suppose to inject only the collaborators you need.

      I believe your application is going to load much faster once you clean out this mess because right now each service instance receives an instance of each DAOs (I hope they aren't prototypes...). No wonder why it is so slow.
      That was the architecture when I came into using the project. I beleive they did it that way to avoid headaches in configuration but I've always thought it was a bit insane to give each service access to every dao... The Dao's are singleton's, but I'm going to start refactoring the services to only load what they require.

      Thanks

      Comment

      Working...
      X