MongoDB 副本集中的每台服务器都需要拥有完全相同的 RAM 吗?
我可以使用具有不同 RAM 量的服务器在 MongoDB 1.8 中设置副本集吗?
- server1: 5gb
- server2: 2gb
- server3: 4gb
如果是,有何优缺点?
Can I set up a replica set in MongoDB 1.8 using servers with different amounts of RAM?
- server1: 5gb
- server2: 2gb
- server3: 4gb
If yes, what are the pros and cons?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,您不需要相同的 RAM。 (是的,您可以按照描述设置副本集。)
MongoDB 使用内存映射文件进行所有缓存,这意味着缓存分页由操作系统处理。具有更多内存的副本将在内存中保留更多的数据库;那些较少的将更多地分页到磁盘。
如果可以的话,MongoDB 最终会将整个数据库放入内存中。如果您使用两个副本进行读取,一个用于写入,您可能需要使用 5GB 和 4GB 计算机进行读取,因此它们更有可能占用 RAM。
No, you do not need equal RAM. (Yes, you could set up a replica set as described.)
MongoDB uses memory-mapped files for all caching, which means that cache paging is handled by the operating system. The replicas with more memory will keep more of the database in memory; those with less will page more to disk.
MongoDB will eventually bring the entire database into memory if it can. If you're using two replicas for reads and one for writes, you might want to use the 5gb and 4gb machines for reads, so they are more likely to be hitting RAM.
是的,您可以通过这种方式配置副本集。
这里有一个文档解释了副本集的主要功能。让我们根据 RAM 差异来看看这些。
优点:
缺点:
所以,这里的大问题实际上是性能问题。如果您只是为了开发设置而执行此操作,那么它基本上可以工作。但在生产中,您面临着应用程序完全崩溃的风险。如果您的应用程序习惯于使用 4GB 以上的 RAM,然后突然降至 2GB,则它可能会变得无法使用。
大多数生产设置都希望故障转移到另一台“同等功率”的计算机。
Yes, you can configure a replica set this way.
Here's a doc explaining the major features of replica sets. Let's take a look at these in light of the RAM differences.
Pros:
Cons:
So, the big problem here, is really one of performance. If you're just doing this for a dev setup, then it will basically work. But in production you run the risk of completely tanking your app. If your app is used to living on 4GB+ of RAM and then suddenly drops to 2GB, it may become unusable.
Most production setups want to fail over to another "equally-powered" computer.