views:

624

answers:

2

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?

+2  A: 

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.

Ben Williams
It appears that Pooling and MySql connection limits were the answer.
A: 

Check your mysql configuration (/etc/mysql.conf or it's local equivalent), particularly the max connections and max conn per user settings; this sounds as though it may be coming from mysql and not grails.

Tim Howland