开发者

JBoss connection pool creating many connections to MySQL

开发者 https://www.devze.com 2023-02-18 04:36 出处:网络
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:

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>开发者_Python百科
       <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!


When I experienced this, the problem was that some hibernate sessions were not closed and this cause connection leak. Check that your session close statements are in finally block.


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号