开发者

mongoDB, passenger and performance issues with phusion passenger

i just stumbled across a posing on the mongodb-user list where there was a discussion about passenger and forking when using mongoDB with MongoMapper.

I just wanted to remind that Rails developers need to tweak their 开发者_运维知识库'environment.rb' if they use MongoDB with Passenger.

By default, Passenger spawns Ruby processes with fork(). And, as fork () shares file descriptors, the Rails app has to reopen the connection to MongoDB in the fresh new "process".

http://groups.google.com/group/mongodb-user/browse_thread/thread/f31e2d23de38136a

anyone knows if there are still issues with mongoDB and passenger or what is the best way to serve a mongoDB-rails-application with passenger?


I think this "issue" is still around, but I think the fix was provided in both the thread you linked to (a link in the first message) and in a gist by John Nunemaker (http://gist.github.com/232953).

I believe the relevant bit of information is in the following block of code which you will place in an intializer:

if defined?(PhusionPassenger)
  PhusionPassenger.on_event(:starting_worker_process) do |forked|
    # if using older than 0.6.5 of MM then you want database instead of connection
    # MongoMapper.database.connect_to_master if forked
    MongoMapper.connection.connect_to_master if forked
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜