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

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

문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top