Srikanth Jeeva
Srikanth Jeeva

Reputation: 3011

rails + maximum connection pool size in database.yml

What is the maximum pool size i can set in my database.yml? I'm using Mysql Db.

I have 20 unicorn processes running in 24 core, 32GB RAM machine.

Upvotes: 2

Views: 5149

Answers (1)

gmaliar
gmaliar

Reputation: 5479

The default configuration in MySQL is 100 connections.

From MySQL 5.5 page

Linux or Solaris should be able to support at 500 to 1000 simultaneous connections routinely and as many as 10,000 connections if you have many gigabytes of RAM available and the workload from each is low or the response time target undemanding. Windows is limited to (open tables × 2 + open connections) < 2048 due to the Posix compatibility layer used on that platform.

You'll have to figure it out yourself, I don't think that the simultaneous connections to the DB will be your bottleneck.

From Rails ConnectionPool:

A connection pool synchronizes thread access to a limited number of database connections. The basic idea is that each thread checks out a database connection from the pool, uses that connection, and checks the connection back in. ConnectionPool is completely thread-safe, and will ensure that a connection cannot be used by two threads at the same time, as long as ConnectionPool’s contract is correctly followed. It will also handle cases in which there are more threads than connections: if all connections have been checked out, and a thread tries to checkout a connection anyway, then ConnectionPool will wait until some other thread has checked in a connection.

So the only thing you should not do is have more connections in Rails pool size than in your mysql configuration.

Upvotes: 6

Related Questions