Vince /. wrote:
It seems that a lot of the database logic is hidden away from rails and it would be nice to know how Rails or the MVC handles database connections.
The ISP im with (GoDaddy) only supports 50 mysql connections at a time (simultaneous) and when it comes to Rails, how do I find out when database connections are kept open? Is there some sort of connection pooling that the server must implement in order to get the maximum out of those 50? Does rails keep connections open when working with pagination?
Im basically looking for some resources on how rails maintains its conenctions and how it works with the database overall but google does not help at all.
In all but the simplest server setups (e.g. WEBrick) Rails deployments have a front-end web server distributing requests for dynamic content to a number of Rails server processes. The Rails processes may be set up to be called through a number of different protocols, including FCGI, SCGI, LSAPI, and HTTP.
Each server process is limited to handling one request at a time, and has one database connection. (Pagination doesn't use cursors, so doesn't require successive page requests to re-use the same connection.)
If you search the archives of this list you will find advice about how to tune the number of server processes. A low-volume application may be fine with two or three server processes - you certainly shouldn't need to get anywhere near the 50 processes corresponding to the DB connection limit.