问题
we're on rails 3.2.12, passenger + nginx (1.0.10), mongo 2.2, and mongomapper 0.12.
we were told that passenger and mongo don't work well together unless there is a configuration set to ensure speedy database connections (or reconnections).
however, one person advised us to use the code here: http://pastie.org/572282. then we found this post on stackoverflow (mongoDB, passenger and performance issues with phusion passenger), which is different.
which is the right way to ensure optimal mongo performance with passenger (and nginx)?
回答1:
The method to handle this changed between Mongomapper versions.
The correct way now is to use Mongomapper's convenience method in your initializer:
MongoMapper.connection.handle_passenger_forking
See the source on Github for implementation details.
来源:https://stackoverflow.com/questions/17098660/mongo-passenger-right-way-to-reconnect-to-database-from-within-rails-how-to