With the upcoming thread-safety of Rails comes the necessity of database connection pools. While less a feature and more a hidden implementation detail, you do have the ability to adjust the max size of these new pools (default is 5). In your database.yml configuration file just set the pool key:
1 2 3 4 5 |
development:
adapter: mysql
username: root
database: myapp_dev
pool: 10 |
So there ya go – connection pools. That was easy…
tags: ruby, rubyonrails

Rails 2.2 looks like it may be my favourite release yet.
What is the default size? 10?
Now some guidelines on what a reasonable setting for pools would be useful…
is there any practical reason I would want to do this?
The default pool size is 5.
I think it could be good to have as much connections as you have running servers. How do you think?
Carl: depends on how you plan to run Rails. If you continue to run with multiple Mongrels/Thins or Passenger in a situation where each request has a big mutex around it, the pool size won’t really matter because you’re still only using a single connection at a time.
If you run in full MT mode, the number of connections you need depends on how much parallelism you need in that server. I’d probably do some load testing until I start getting pool timeout errors and then set the pool maximum size comfortably above that.
Hey Ryan, thanks for all of the excellent info! Your blog has been responsible for countless improvements to the efficiency of my coding : )
I do have a suggestion regarding the format of the site: sometimes if I don’t hit the blog in a while, I can’t tell which “Edge Rails” entries refer to the current Edge or versions that have since gone into production. I wonder if you could add the version number somewhere in those entries?
Keep up the great writing!
Michael – great suggestion, I’ll try to keep track of this in the future.
Isn’t it just amazing how simple some people can make things seem when the rest of us go all around the world to do the same thing. Thanks for reminding me to KISS. (Keep It Simple Stupid)
KeeKee
well, twitter.com needs a code refactor now :-)
Nick, what do you mean my MT mode? Multi Threaded? If so, how do you run rails in this mode? Jruby?