Announcement Announcement Module
Collapse
No announcement yet.
Spring Performance with Oracle RDBMS - A Question ! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Performance with Oracle RDBMS - A Question !

    I am using oracle 11g and i have an application which is coded in Spring framework. Once i configure the database on Sun fire 4170 installed with Linux the machine's CPU utilization is around 80-100% and, however, when i shift the same database to Sun M3000 server installed with Unix OS (supposedly more powerful machine) the application performance goes down and CPU utilization remains 90-100%. I can't figure out if its the application which is making the such utilization or its the database design. It is added that the database is not relational; things are handled by the application.

    Now this is what people are saying in response to my question.

    Oracle is an RDBMS. Using it with a framework like Spring will have dramatic impacts on performance. Spring makes coding faster, not databases. I guarantee you'll find a lot of iterations over every row, one-at-a-time. At least, that's what I've found when looking at databases built by programmers who use frameworks.

    Do we have someone who could defend Spring framework..?

  • #2
    The only iteration done in spring (if you use plain jdbc!) is when you use a RowMapper (and that is just once). Basically spring-jdbc behaves just as you would write your own jdbc code...

    A lot of performance issues arise with wrong/absent transaction configuration, wrong model, no connection pool, slow connections/network latency, lots and lots and lots of data and not using paging or cursors but trying to do everything in memory. Also the fact that your database isn't relation can also be a problem (you have a full blown RDBMS use it it is more then just a drawer to put papers in...).

    Also CPU utilization doesn't say everything, sometimes the database is performing in memory calculations/caching to keep performance up (which is mostly in lower prioritized processes as other processes) which might make it look like 80% cpu is bad.

    However saying what the problem is or giving you a solutionis difficult without further analysis and some code/metrics etc.

    Comment


    • #3
      Originally posted by Marten Deinum View Post

      However saying what the problem is or giving you a solutionis difficult without further analysis and some code/metrics etc.
      Thanks for a nice & to the point answer but i just want to know, what i as a developer have to look into my code to make it perfect & what sort of analysis should i perform. Secondly i am using both hibernate and JDBC templates and i am also using pagination. So far no cursors have been made.And yes i have also used a bit of AOP for primary key generation stuff. I hope thats safe...
      Ah...I have people which are now questioning me about Spring Performance as a framework. The application works fine till i am developing on my CPU but when it is shifted to IBM websphere (Application servers) and Oracle installed DB servers ..things get out hands. Application gives a very poor response.

      Comment


      • #4
        As stated

        1) Use a connection pool
        2) Don't recreate an ApplicationContext
        3) Use spring managed transactions and properly configure them (that way you reuse the connection)
        4) You use hibernate either use HibernateTransactionManager (and only that) or JtaTransactionManager (if you use jta) don't use multiple tx managers
        5) Make sure hibernate is working as expected (don't create/open sessions your self (i.e sessionFactory.openSession) )
        6) You are using hibernate but your database isn't relational that might be troublesome.
        7) If you are using queries and have lots of data make sure you have indexes etc. in place.

        Also make sure that the problem is your application and not your database or app server configuration.

        I have used hibernate(jpa) and jdbc mixed in small and very large applications with lots of data without any problems, so there shouldn't be an issue.

        Perform analysis use something for monitoring your application like YourKit or use tc-server with spring insight to do some analysis to find problematic locations in your code. Tools like findbugs and pmd can do static analysis to indicate some problematic code parts also.

        Comment


        • #5
          Originally posted by Marten Deinum View Post
          As stated


          2) Don't recreate an ApplicationContext
          .
          This means we can't have more than one applicationContext in an application. Probably i fail to understand the essence of the sentence.....

          Comment


          • #6
            If you create a new instance of the context it also means it instantiates the datasource, tx manager basically everything again. Which means you end up with 2 instances. If you do it again 3 etc. slowly eating up memory, database resources etc. You should only have need for 1 applicationcontext which wires everything together. Or at least have a clear seperation, basically if you do a new ApplicationContext somewhere in your application you are heading to a dark path...

            Comment


            • #7
              Originally posted by Marten Deinum View Post
              If you create a new instance of the context it also means it instantiates the datasource, tx manager basically everything again. Which means you end up with 2 instances. If you do it again 3 etc. slowly eating up memory, database resources etc. You should only have need for 1 applicationcontext which wires everything together. Or at least have a clear seperation, basically if you do a new ApplicationContext somewhere in your application you are heading to a dark path...
              What i have read is that the DispatcherServlet will construct the Spring Application Contextby reading a file whose name follows the servletname-context.xml. An Application Context usually represents a set of Configuration files that are used to provide configuration information to the application. The Application Context is a XML file that contains various Bean Definitions. This should be ready before the DispatcherServlet attempts to construct the web components, Spring web application use the ContextLoaderListener to construct the bowels of the application, even before the DispactherServlet sees the first request. The listener looks for /WEB-INF/applicationContext.xml by default, but you want to override it using the context parameter contextConfigLocation as shown below.
              <listener>
              <listener-class>
              org.springframework.web.context.ContextLoaderListe ner
              </listener-class>
              </listener>

              <context-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>/WEB-INF/applicationContext-*.xml</param-value>
              </context-param>


              By following this i have made several applicationContext in my application like
              1. applicationContext-aop.xml
              2. applicationContext-persistance.xml
              3. aplicationContext-datasoure.xml etc etc

              Now, after reading your reply i am in doubt if i had coded the right thing. Please put me wise on this, grateful.

              Comment


              • #8
                There is nothing wrong with your setup (at least configuration wise). This holds as long as there is no new ApplicationContext/BeanFactory some where in your java code, because that would create a new instance of the context again... (Although I doubt that is the case here, but I've seen that more then once).

                Comment


                • #9
                  A couple of questions
                  1. Is your application located on the same machine as a DB? If not on which of them CPU consumption goes high?
                  2. What you mean by "database is not relational"?

                  and few remarks -
                  1. A statement "Oracle is an RDBMS. Using it with a framework like Spring will have dramatic impacts on performance." is a pure nonsense, yes, performance impact may exists, but it is hardly measurable.
                  2. If DB server becomes overloaded or performs poorly it is the most likely due to either a bad DB design or a poorly coded application (e.g. you strive to do procedurally what should be done with a single SQL statement)
                  3. If your application server suffers - it is almost for sure due to a bad application design/architecture (while I have met very strange sources of a poor performance).

                    Please, provide more details if you need more specific suggestions.

                  Comment


                  • #10
                    you can use SQL server. it will work.

                    Comment

                    Working...
                    X