Announcement Announcement Module
Collapse
No announcement yet.
seperation of process Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • seperation of process

    Hi,
    I have an application using Struts, Spring and Hibernate. My hibernate's session factory is a, expensive object and it takes a long time to load the factory. This is affecting the Application startup which cannot be afforded by an application. I want to separate this session factory loading from the main application startup and the application server startup.

    Please suggest me of how to go about for the same.

    Thanks in Advance,
    Sudha

  • #2
    I really do not see big sense in such separation - anyway you application likely will be unusable till initialization of session factory completes.

    And what is "long"? 20 seconds, 30 seconds? It is very unlikely, that it takes much more. Why it can not be tolerated once, when application is loaded by application server? How often it occurs (in the production environment)? Once a day? Or even more seldom.

    Or do you instantiate session factory for each user session?`If so, then it is design bug and you should use single instance of session factory for the whole application.

    Regards,
    Oleksandr

    Originally posted by sudha_parimala View Post
    Hi,
    I have an application using Struts, Spring and Hibernate. My hibernate's session factory is a, expensive object and it takes a long time to load the factory. This is affecting the Application startup which cannot be afforded by an application. I want to separate this session factory loading from the main application startup and the application server startup.

    Please suggest me of how to go about for the same.

    Thanks in Advance,
    Sudha

    Comment


    • #3
      Yeah this does sound strange. My application takes 20 seconds to start, not really much of a problem. What's the exact problem you have with this?
      Last edited by karldmoore; Aug 27th, 2007, 04:50 PM.

      Comment


      • #4
        Originally posted by karldmoore View Post
        Yeah this does sound strange. My application takes 20 seconds to start, not really much of a problem. What's the exact problem you have with this?
        And "exact problem" means "quantified problem", i. e. my application starts XXX seconds (minutes, hours, days ), but maximum tolerable startup time is XX seconds. And I have found that from XXX seconds YYY are spend for SessionFactory initialization Not just I guess that SessionFactory munches the lion part of it.

        Regards,
        Oleksandr

        Comment


        • #5
          Only the part of an application is using these technologies. We have a huge database for the hibernate OR mapping. The base application doesn't use any OR mapping stuff and that's straight forward. This part occupies the major part of an application. Spring, Hibernate is used only in a part of application.

          Whenever the application restarts ( this happens more often) i don't want the sessionfactory to be loaded every time.

          pls let me know if any more clarifications ore needed.

          Note: The startup takes 10-15 minutes.

          Sudha

          Comment


          • #6
            Originally posted by sudha_parimala View Post
            The startup takes 10-15 minutes.
            Wooohooo! However you have achieved that!?

            What about just lazy-loading it - and of course any object that references it as well?

            Jörg

            Comment


            • #7
              Yeah, currently doing the same... But i also want to give an alternative as Loading the whole stuff outside the application server and accessing it with some service locator

              Guys, this is really important for me.. Looking forward for ur suggetions.


              Sudha

              Comment


              • #8
                I might be wrong, but I would attack the actual problem. 10 to 15 minutes is WAY too much for me even with a huge database.

                Jörg

                Comment


                • #9
                  Hmmm, I would like to do the same.....
                  I 'll give u info about our data model may be u can give me some pointers of how to go about this.

                  Our data model is having around 2000+ tables. the associations are also closely knitted. For some reasons i must do the entire data loading with which i can't avoid any objects..... is there a way we can dynamically load the objects only on demand and the same for the the associated objects also...

                  Sudha

                  Comment


                  • #10
                    Originally posted by sudha_parimala View Post
                    ...
                    Note: The startup takes 10-15 minutes.

                    Sudha
                    And how much of that time is eaten by session factory creation?

                    BTW, creation of session factory does not load any objects from DB, so if your concern is time needed to load your data, then isolation of session factory creation would not help.

                    As well 2000 tables in DB sounds way to many. It may not be said for sure without knowing the tasks, but I'm strong feelings that DB is badly misdesigned.

                    For some reasons i must do the entire data loading with which i can't avoid any objects.....
                    What exactly you mean? Do you load the whole DB (i.e. data) in the memory or you are just speaking about loading of Hibernate mappings?

                    If former, then it is a heavy misuse of Hibernate application for sure need redesign (or at least tweaking of Hibernate mappings to allow lazy loading of objects, look in Hibernate documentation for details).

                    If latter, then you may try to switch from using of Hibernate XML-mappings to annotations (while with your amount of tables and classes it would be a huge task).

                    And, BTW, what is behind "...some reasons..."?

                    Regards,
                    Oleksandr

                    Comment


                    • #11
                      What may help you to improve startup time is dynamic-insert=true and dynamic-update=true in your class mappings. The problem is that these settings can not be specified globally and as well are not inherited, so they shall be specified individually on each class, subclass and joined-subclass element in your mappings.

                      In the presence of these settings Hibernate does not try to generate and cache for future use insert and update statements for each and every table in mapping right on startup, but does it only when statement has to be used (in which case only affected columns are included in the statement). Some times it is good for performance, sometimes -bad, but anyhow for big schemas startup time is be greatly reduced.

                      Another possible optization is to mark all immutable classes (if any) as such (mutable="false"). "Immutable" in this context means that your application never update or delete objects of this classes in/from DB.

                      Regards,
                      Oleksandr


                      Originally posted by sudha_parimala View Post
                      Hmmm, I would like to do the same.....
                      I 'll give u info about our data model may be u can give me some pointers of how to go about this.
                      Our data model is having around 2000+ tables. the associations are also closely knitted. For some reasons i must do the entire data loading with which i can't avoid any objects..... is there a way we can dynamically load the objects only on demand and the same for the the associated objects also...

                      Sudha

                      Comment


                      • #12
                        As has already been said, it would be useful to narrow down exactly what is taking the time. Presumably it is your LocalSessionFactoryBean. It does sound like you want to allow different parts of your context to be restarted and others to be left alone. Have you looked into OSGi?
                        Last edited by karldmoore; Aug 27th, 2007, 04:49 PM.

                        Comment


                        • #13
                          Hi Karl,
                          I am trying to look into the actual content that's loading time. meanwhile i'll also look into OSGi. Tks for your valuable suggestions. I'll keep posing my findings. pls let me know if you have any other suggestions.

                          Regards

                          Comment


                          • #14
                            Originally posted by sudha_parimala View Post
                            I am trying to look into the actual content that's loading time.
                            That would be useful to know, it does sound like an awful long time to startup.

                            Originally posted by sudha_parimala View Post
                            meanwhile i'll also look into OSGi.
                            I'm not sure if it will help, but it does seem like you potentially want to take part of the application down and leave the rest running. This could be an interesting fit.

                            Originally posted by sudha_parimala View Post
                            Tks for your valuable suggestions. I'll keep posing my findings. pls let me know if you have any other suggestions.
                            Looking forward to seeing what you come back with!
                            Last edited by karldmoore; Aug 27th, 2007, 04:49 PM.

                            Comment

                            Working...
                            X