主从复制;读分割策略
我们即将要求在 MySQL 数据库上进行复制,我正在寻找有关最佳策略的一些说明。希望这里提出的问题仍然足够具体。
目前,我们的应用程序有 1 个数据库,这是相当读取密集型的。我正在考虑从一个简单的主从设置开始,其中读取将根据应用程序内的一些基本负载平衡逻辑,将大约 40% 分配给主设备,将 60% 分配给从设备。
我说过 40-60 的分割是因为有一些偶尔的读取,我知道这些读取需要很长时间才能执行,可能是一分钟或更长时间。我计划始终将这些读取定向到主服务器,而不是对这些读取进行负载平衡。我宁愿让主站完成工作并给从站时间来赶上,而不是在更简单的查询上可能引入复制滞后。 (当我们可以升级到多个从站时,我们将有一个专门用于这些密集查询)。
所以我想我的问题是 - 这听起来像是一个明智的计划吗?如果不是,什么是更好的选择?
编辑以回应以下评论:
@Romain - 应用程序的很大一部分涉及登录用户发帖、评论和回复,因此对于这些操作,需要尽可能避免过时的数据。
@Jaydee - 是的,我为每个服务器内置了一个权重值,这样我就可以根据需要轻松更改读取百分比。
We're close to requiring replication on our MySQL database, and I'm looking for a bit of clarification on the best strategy. Hopefully this is still specific enough a question to be asked here.
We currently have 1 DB for our application which is fairly read-intensive. I'm thinking of starting with a simple master-slave setup where reads will be split around 40% to the master and 60% to the slave, based on some rudimentary load-balancing logic within the application.
I've said a 40-60 split as there are some occasional reads which I know will take a long time to execute, potentially a minute or longer. Rather than load balancing these reads, I plan on always directing these to the master. I'd rather have the master do the work and and give the slave time to catch up, rather than potentially introduce replication lag on simpler queries. (When we can advance to multiple slaves, we'll have one dedicated to these intensive queries).
So I guess my question is - does this sound like a sane plan, or if not what would be a better alternative?
Edit in response to the comments below:
@Romain - A large part of the application involves signed-in users posting, commenting and replying, so for these operations stale data needs to be avoided where possible.
@Jaydee - yes, I've built in a weighting value for each server so I can easily change the read % if needed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论