Search code examples
javamysqljbossconnection-pooling

JBoss connection pool creating many connections to MySQL


We are using a setup of JBoss 4.2.2.GA / Hibernate 3.2.4.sp1 / SpringMVC 2.5 / MySQL 5.0.27.

Below is the mysql-ds.xml file:

<datasources>
  <local-tx-datasource>
    <jndi-name>myDS</jndi-name>
    <connection-url>jdbc:mysql://127.0.0.1:3306/database?zeroDateTimeBehavior=convertToNull&amp;useConfigs=maxPerformance</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>user</user-name>
    <password>password<password>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
    <min-pool-size>5</min-pool-size>
    <max-pool-size>100</max-pool-size>
    <blocking-timeout-millis>30000</blocking-timeout-millis>
    <idle-timeout-minutes>1</idle-timeout-minutes>
    <metadata>
       <type-mapping>mySQL</type-mapping>
    </metadata>
  </local-tx-datasource>
</datasources>

Looking at the JMX-Console -> service=ManagedConnectionPool, we are using JBossManagedConnectionPool.

Now, the problem is that even with mediocre traffic (site attracted approx 5000 Visits / 15000 pageViews yesterday), there are 96 threads in sleep mode on MySQL (got using show processlist).

These do get reduced in time but my real question is, why is jboss creating so many connections? MaxConnections on MySQL = 250.

Any help appreciated!


Solution

  • After much analysis, it was discovered that Hibernate was issuing too many queries in the back-end to load certain mappings, as mysqladmin status command gives 500 queries / sec.

    Resolving this should resolve this problem as well.

    Thanks to everyone who helped...