JBoss 连接池创建许多与 MySQL 的连接
我们使用的设置是 JBoss 4.2.2.GA / Hibernate 3.2.4.sp1 / SpringMVC 2.5 / MySQL 5.0.27。
下面是 mysql-ds.xml 文件:
<datasources>
<local-tx-datasource>
<jndi-name>myDS</jndi-name>
<connection-url>jdbc:mysql://127.0.0.1:3306/database?zeroDateTimeBehavior=convertToNull&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>
查看 JMX-Console -> service=ManagedConnectionPool,我们正在使用JBossManagedConnectionPool
。
现在的问题是,即使流量平庸(昨天网站吸引了大约 5000 次访问/15000 次页面浏览),MySQL 上仍有 96 个线程处于睡眠模式(使用 show processlist
)。
这些确实会随着时间的推移而减少,但我真正的问题是,为什么 jboss 创建这么多连接? MySQL 上的最大连接数 = 250。
感谢任何帮助!
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&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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我遇到这个问题时,问题是一些休眠会话没有关闭,这导致连接泄漏。检查您的会话关闭语句是否位于finally 块中。
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.
经过大量分析,发现 Hibernate 在后端发出太多查询来加载某些映射,因为 mysqladmin status 命令每秒提供 500 个查询。
解决这个问题也应该解决这个问题。
感谢所有帮助过的人...
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...