【问题标题】:Grails/Hibernate Database crashes under load: Unable to connect (even when pooling)Grails/Hibernate 数据库在负载下崩溃:无法连接(即使在池中)
【发布时间】:2010-10-08 22:45:31
【问题描述】:

我在 Grails 中有一个应用程序。 我使用 Hibernate 访问数据库(根据标准 grails 规则) 我使用 MySql,网站运行稳定(6 个月)。

我正在做负载测试,最近发现数据库在负载下拒绝连接。

使用 MySQL Server 5,我可以看到连接的线程在 20 左右徘徊。我认为我在 11 - 30 之间跳跃。

mysql> show status like '%con%';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| Aborted_connects         | 72    |
| Connections              | 65539 |
| Max_used_connections     | 101   |
| Ssl_client_connects      | 0     |
| Ssl_connect_renegotiates | 0     |
| Ssl_finished_connects    | 0     |
| Threads_connected        | 1     |
+--------------------------+-------+
7 rows in set (0.00 sec)

我的数据库配置是标准的。 (MySql服务器安装在本地,未显示)

dataSource {
    pooled = false
    driverClassName = "com.mysql.jdbc.Driver"
    username = "username"
    password = "secret"

    maxIdle = 15
    maxActive = 100        
}

我应该调查 C3P0 吗?或者我应该将我的 maxActive 提高到 1000 并希望获得最好的结果?

【问题讨论】:

    标签: mysql performance hibernate grails scale


    【解决方案1】:

    Grails 无法获得数据库连接时会报告什么错误?暂停?拒绝?

    运行测试时,盒子的负载如何? CPU 百分比、内存使用率等。

    可能是数据库过载,以至于 Grails 正在超时获取连接。如果要处理负载,则需要使用池化数据库连接。如果没有池化,Grails 将在每个请求中打开和关闭一个数据库连接。

    【讨论】:

    • 看来池和 MySql 连接限制是答案。
    【解决方案2】:

    检查您的 mysql 配置(/etc/mysql.conf 或本地等效配置),特别是每个用户设置的最大连接数和最大连接数;这听起来好像它可能来自 mysql 而不是 grails。

    【讨论】:

      猜你喜欢
      • 2012-04-20
      • 1970-01-01
      • 2021-09-27
      • 1970-01-01
      • 2016-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多