codecompleting
codecompleting

Reputation: 9621

Does Rails create any connection pools to mysql? Is it a single threaded design?

How are connections to mysql handled in Rails 3?

Do multiple connections to the website share the same mysql connection, or does it take a connection from a connection pool and then release it once the request has closed all connections to mysql?

If there are 10 front end servers all hitting a single db server, are there any issues here?

I' using Phusion passenger if that effects anything.

Upvotes: 3

Views: 462

Answers (1)

apneadiving
apneadiving

Reputation: 115541

The doc answers by itself:

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.

Upvotes: 1

Related Questions