When doing performance in local box, we found that requests are waiting to be processed due to Rails is single-threaded by default. We changed the configuration to enable multi-threaded mode as described in this blog entry:

Thread safety for your Rails

(also refer to Rails 2.2 release notes )

The most important change was to eager-load /lib directory, and thus move libraries for test out of it.

config.threadsafe! also disables automatic loading by ActiveSupport::Dependencies. Alternatively, you can just add lib/ directory to eager load paths. The following inside production.rb will do that :
config.eager_load_paths << "#{RAILS_ROOT}/lib"

We had some rough tests to ensure the functionality is not broken. Multi-threaded mode also might require more memory than single-threaded mode. Still keep testing.

Leave a Reply