After problems with connection leak and deadlocks in DBCP we made a decision to replace it with Tomcat JDBC-pool. Of course migration was really simple.
But after deploy it on a production environment I noticed, that load on a server with running two Tomcats increase from 4-4.5 to 5.5. We didn't do anything more, except change of pool. Moreover, performance measured with JMeter decrease by about 5%.
I spent some time to tune pool parameters, but without visible effects. I pasted my current config (from <GlobalNamingResources>
in server.xml
) below:
<Resource name="jdbc/xxxxxx"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
initialSize="10"
maxActive="100"
minIdle="10"
maxIdle="50"
maxWait="10000"
testOnBorrow="true"
testOnReturn="false"
testOnConnect="false"
testWhileIdle="false"
validationQuery="SELECT 1 from dual"
validationInterval="30000"
suspectTimeout="60"
timeBetweenEvictionRunsMillis="30000"
removeAbandonedTimeout="60"
removeAbandoned="true"
logAbandoned="true"
abandonWhenPercentageFull="50"
minEvictableIdleTimeMillis="60000"
jmxEnabled="true"
username="xxxxx"
password="xxxxx"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:oci:xxxxx"/>
FairQueue and PoolSweeperEnabled are true
In Spring applicationContext-jdbc.xml I have only:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="resourceRef">
<value>true</value>
</property>
<property name="jndiName">
<value>java:comp/env/jdbc/PortalDB</value>
</property>
</bean>
What am I doing wrong? I thought, that JDBC_pool should be faster than DBCP out of the box.
Your settings and tuning appear correct. Your load increase may be as a result of the server handling more concurrent requests at the same time. DBCP may have prevented the server to take on this load because of how it locked the pool from all threads. The jdbc-pool doesn't do this, so now you've increased your concurrency. And if the load increases, the response may decrease, but your throughput would increase.
I'd start tuning
maxActive
to match your maxThreads in order to handle concurrency.