我应该在它自己的 EC2 实例上运行 MongoDB 吗?

发布于 2024-12-25 10:33:25 字数 261 浏览 2 评论 0原文

我刚刚开始使用 Amazon EC2,并试图了解数据库应该如何工作。如果我有一个高流量站点并且想要在多个实例上对流量进行负载平衡,我猜测这些实例必须检索数据并将其保存到单个单独的实例中,以避免数据在多台计算机上碎片化。

在这种情况下,我应该在自己的实例上安装并运行 mongoDB 并将所有其他实例连接到这个单一数据存储吗?或者我应该在同一个实例上运行 mongo 和我的 http 服务器?

很想听听您的一些最佳实践。

I'm just getting started with Amazon EC2 and trying to get my head round how the databases should work. If I have a high traffic site and want to load balance traffic over multiple instances I'm guessing these instances will have to be retrieving and saving data to a single separate instance to avoid data being fragmented across multiple machines.

Should I in that case install and run mongoDB on its own instance and have all other instances connect to this single data store? Or should I just run mongo and my http server on the same instance?

Would love to hear some of your best practices.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初熏 2025-01-01 10:33:25

也许在开发时没有必要,但一旦投入生产就应该这样做。

更重要的是,如果您正在运行生产数据,您可能希望运行副本集 在发生故障时进行备份,不会丢失数据,也不会中断服务。

数据库需要内存,因此必须与其他进程共享内存是一个坏主意。在应用程序服务器上,您可能需要比内存更多的 CPU,因此您可以使用高 CPU 实例类型(c.medium、c1.xlarge)并为数据库使用高内存类型(m2.large 等)(高 CPU实例更便宜)

此外,从架构的角度来看,最好能够独立于数据库扩展应用程序服务器的数量。如果您将应用程序服务器和数据库放在同一台计算机上,如果稍后必须迁移到另一台计算机,则可能会导致问题。

Maybe it's not necessary while you're developing, but you should do it once you go to production.

Even more, if you are running production data, probably you want to run a replica set to have a backup in case something fails, to not lose your data and not interrupt your service.

DBs are hungry for memory, so having to share it with other processes it's a bad idea. On an application server you probably need more CPU than memory, so you can use High-CPU instance types (c.medium, c1.xlarge) and use High-Memory types for your DB (m2.large, etc) (High-CPU instances are cheaper)

Also, from architectural point of view, it's better to be able to scale the number of app servers independently from the DB. If you put the app servers and the DB on the same machine, that could lead to problems if you have to migrate to a different one later.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文