mongo + 乘客:从 Rails 内重新连接到数据库的正确方法?如何确保最佳 mongo 性能? [英] mongo + passenger: right way to reconnect to database from within rails? how to ensure optimal mongo performance?

查看:51
本文介绍了mongo + 乘客:从 Rails 内重新连接到数据库的正确方法?如何确保最佳 mongo 性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在 Rails 3.2.12、passenger + nginx (1.0.10)、mongo 2.2 和 mongomapper 0.12 上.

we're on rails 3.2.12, passenger + nginx (1.0.10), mongo 2.2, and mongomapper 0.12.

我们被告知,passenger 和 mongo 不能很好地协同工作,除非有一个配置集来确保快速的数据库连接(或重新连接).

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

但是,有人建议我们使用此处的代码:http://pastie.org/572282.然后我们在 stackoverflow 上找到了这篇文章(mongoDB,phusion 的乘客和性能问题乘客),这是不同的.

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.

确保乘客(和 nginx)获得最佳 mongo 性能的正确方法是什么?

which is the right way to ensure optimal mongo performance with passenger (and nginx)?

推荐答案

处理此问题的方法在 Mongomapper 版本之间发生了变化.

The method to handle this changed between Mongomapper versions.

现在正确的方法是在初始化程序中使用 Mongomapper 的便捷方法:

The correct way now is to use Mongomapper's convenience method in your initializer:

MongoMapper.connection.handle_passenger_forking

查看 Gith 上的源代码.

See the source on Github for implementation details.

这篇关于mongo + 乘客:从 Rails 内重新连接到数据库的正确方法?如何确保最佳 mongo 性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆