mongo + passenger: right way to reconnect to database from within rails? how to ensure optimal mongo performance?

StackOverflow https://stackoverflow.com/questions/17098660

Question

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)?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top