Hi,
At my current client we have an application which turns out to use only 30% of its original CPU usage just by changing one hibernate setting. The application does only selects, no updates. We don't understand this behavior.
Our config is detailed below.
Does anyone have a clue why we use 70% less cpu with this small change? Has anyone ever seen something similar?
Any insight is welcome,
Richard
The hibernate properties are as follows. The change is for hibernate.connection.release_mode from auto to after_transaction
We use a org.springframework.orm.hibernate3.LocalSessionFactoryBean as sessionFactory.
With the following configuration:
Code:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
...
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>
<prop key="hibernate.jdbc.batch_size">20</prop>
<!-- <prop key="hibernate.connection.release_mode">auto</prop> -->
<prop key="hibernate.connection.release_mode">after_transaction</prop>
</props>
</property>
</bean>
The defined dataSource is a Websphere 6 jdbc connection pool and it is Non-XA. It is connected to an Oracle 9 RAC cluster.
The transaction manager which is defined is:
Code:
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
There is no transactionFactory defined, so I guess the Hibernate default JTATransactionFactory is used since we are inside Websphere and have JTA support. If so, the default connection release mode for auto is AFTER_STATEMENT. But this is purely derived from documentation:
http://community.jboss.org/wiki/Sessionsandtransactionshttp://www.redhat.com/docs/en-US/JBoss_ ... Modes.htmlThe web.xml configuration we use pretty standard spring stuff:
Code:
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<!-- Configuring Servlet mapping for Spring MVC's servlet actions -->
<servlet>
<servlet-name>page</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>update</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<!-- Configuring Servlet mapping for Spring MVC's servlet actions -->
<servlet>
<servlet-name>page</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>update</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>