Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails/Hibernate Database crashes under load: Unable to connect (even when pooling)

I have an application in Grails. I use Hibernate to access the database (per standard grails rules) I use MySql and the site works and is stable (for 6 months).

I am doing load testing, and recently discovered that the database rejects connections when under load.

Using MySQL Server 5, I can see threads connected hovering around 20. Thought i jumps between 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)

My database configuration is standard. (The MySql server is installed locally, not shown)

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

    maxIdle = 15
    maxActive = 100        
}

Should I investigate C3P0? Or should I ratched up my maxActive to 1000 and hope for the best?

like image 788
user57660 Avatar asked Oct 14 '22 17:10

user57660


1 Answers

What error is Grails reporting when it can't get a database connection? Timeout? Refused?

When you run your test, how loaded is the box? Percent CPU, memory usage, etc.

It's possible the database is just so overloaded that Grails is timing out getting connections. If you want to handle load, you will want to go to pooled DB connections. Without pooling, Grails will open and close a DB connection with each request.

like image 124
Ben Williams Avatar answered Oct 26 '22 23:10

Ben Williams