mongodb 与 mysql 易于扩展
我正在创建一个 Grails 应用程序,它是移动应用程序的后端。目前它部署在 Amazon EC2 上。它将数据保存到 mysql 数据库。当前指向数据库的一个实例。我计划在负载均衡器后面部署应用程序的多个实例,并最终将读取请求发送到数据库的从属实例。我们计划在未来几个月内发布,并拥有一个由几千名用户组成的测试组。它的读取强度大于写入强度。
我们研究了使用 mongodb 而不是 sql,并将其视为一个很好的解决方案。
如果没有太多扩展 mysql (或 mongodb )的经验,扩展 mongodb 会更容易,因为它具有自动分片等功能。 (寻找做过这两种工作的人的想法)我认为现在切换到 mongodb 会比处于“生产”状态并不得不迁移更容易。
想法?
I am creating a Grails application that is the backend for a mobile application. It is currently deployed on Amazon EC2. It persists data to a mysql database. One instance currently pointing to the database. I plan to deploy multiple instances of the app behind a load balancer and eventually have read requests go to slave instances of the db. We plan to release in the coming months and have a beta group of a couple of thousand users. It is more read intensive than write.
We have looked into using mongodb instead of sql and see it as a good solution.
Not having a lot of experience scaling mysql ( or mongodb ) would it be easier to scale mongodb since it has features such as auto sharding. ( Looking for thoughts from people who have done both ) I am of thinking it will be easier to switch to mongodb now rather than be in 'production' and having to migrate.
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MongoDB 有两个版本的“缩放”:
它们不是灵丹妙药,但都很容易设置。副本集具有自动故障转移功能,这在使用 EC2 时实际上是必不可少的(它们具有随机故障节点的良好历史)。当您需要写入扩展时,MongoDB 有记录的升级流程< /a> 您的副本集为一系列分片副本集。
不幸的限制是(我上次检查过),像 scalr 这样的东西并不真正支持自动缩放。因此,您必须推出自己的解决方案来添加和删除集合中的节点。
一些重要的注意事项:
在某种程度上,扩展将是一个“难题”。 MongoDB 擅长的地方是提供了一种通过复制真正水平扩展大量盒子的方法。根据我的经验,MySQL 的写入确实达到了大约两个框。您可以轻松配置 co-masters,但之后您必须开始处理各种分区,并且基本上失去了进行连接的能力。
它可能会。
从小处开始。让一件作品发挥作用,看看您是否喜欢它的运作方式。如果您有权访问 EC2 帐户,则可以轻松启动几台机器并进行游戏。 MongoDB 不是万能药,但它确实可以很好地解决许多现代 Web 问题。只需衡量您需要连接的程度:)
MongoDB has two versions of "scaling":
They're not silver bullets, but they're both very easy to set up. Replica sets have auto-failover which is practically essential when using EC2 (they have a good history of just randomly failing nodes). When you need write scaling, MongoDB has documented processes for upgrading your replica set to a series of sharded replica sets.
The unfortunate limitation is that (last I checked), things like scalr don't really support automatic scaling. So you'll have to roll your own solution for adding and removing nodes from the set.
Some important considerations:
At some level scaling is going to be a "hard" problem. What MongoDB does well is provide a way to really scale out lots of boxes horizontally with replication. In my experience, MySQL really tops out at around two boxes for writes. You can easily configure co-masters, but after that you have to start mucking around with all kinds of partitioning and you basically lose the ability to do joins.
It probably will.
Start small. Get one piece working and see if you like how it works. If you have access to an EC2 account, then it's easy to spin up a couple of machines and play. MongoDB is not a panacea, but it works really well for a lot of modern web problems. Just measure how badly you need joins :)