Question

Some time ago we've moved one of our web apps from Resin and Java 6 to VMware vFabric tc Server and Java 7. This also included moving all JNDI datasources from Resin implementation to Oracle UCP. I've noticed that my CPU usage is extremely high, when I run the app locally. After attaching VisualVM to tc I've found that it is Oracle UCP who is consuming my CPU:

enter image description here

My local configuration is: Windows 7x64, Java 1.7.0_25x32 (JDK) and vFabric tc Server standard 2.7.0.RELEASE. Here is how I configure datasources in context.xml:

  <WatchedResource>WEB-INF/web.xml</WatchedResource>

  <Resource name="jdbc/oracle"
            auth="Container"
            factory="oracle.ucp.jdbc.PoolDataSourceImpl"
            type="oracle.ucp.jdbc.PoolDataSourceImpl"
            connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource"
            url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=h1.com)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=h2.com)(PORT=1521))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SERVICENAME)))"
            user="user"
            password="password"
            minPoolSize="0"
            initialPoolSize="1"
            maxPoolSize="50"
            ONSConfiguration="nodes=h1:6200,h2:6200"
            connectionWaitTimeout="60"
            inactiveConnectionTimeout="900"
            abandonedConnectionTimeout="900"
            fastConnectionFailoverEnabled="false"
            validateConnectionOnBorrow="true"
            connectionPoolName="NAME"/>

It is interesting that on prod boxes everything works fine. I do not know exact configuration but we have Fedora or CentOS installed on them and Hotspot 7.

I've tried standard Tomcat datasource implementation but it does not work well in my case: the connection between my local machine and DB cluster is very unstable so it is vital for me to have auto-recovering and load-balancing. Also, I want my local config to be similar to prod, so using another pool is undesirable.

Maybe someone faced the same problem and knows the solution? Maybe some JVM arg or native library is missed?

Was it helpful?

Solution

Kindly consider to reduce the timeout seconds of below parameters since it may be one of the contributing factors

1)inactiveConnectionTimeout

2)abandonedConnectionTimeout

More time spent in the idle connections(both borrowed and available) will require more memory to hold the connections.

With the web application being used this may indirectly cause more CPU to be used due to high memory usage .

Please find the links below for more information

Optimizing Universal Connection Pool Behavior

CPU usage VS RAM

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top