Redis 模仿 MASTER/MASTER?或者是其他东西? [英] Redis mimic MASTER/MASTER? or something else?

查看:51
本文介绍了Redis 模仿 MASTER/MASTER?或者是其他东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读这里的很多帖子并浏览网页,但也许我没有问正确的问题.我知道 Redis 目前是主/从,直到集群可用.但是,我想知道是否有人可以告诉我如何在逻辑上配置 Redis 以满足我的需求(或者它不是正确的工具).

I have been reading a lot of the posts on here and surfing the web, but maybe I am not asking the right question. I know that Redis is currently Master/slave until Cluster becomes available. However, I was wondering if someone can tell me how I would want to configure Redis logistically to meet my needs (or if its not the right tool).

场景:

我们在美国的两端有 2 个站点.我们希望客户能够在每个站点进行大量写作.然后我们希望每个客户端也能够在他们的站点上执行读取.然而,我们希望数据可以从 <姊妹站点的写入中获得.50 毫秒.鉴于我们有足够的带宽.有没有办法配置redis来满足我们的需求?我们的写入最大大小通常在 5k 左右.主要的一点是,即使默认情况下不支持,我如何才能拥有 2 个相互同步的 master.

we have 2 sites on opposite ends of the US. We want clients to be able to write at each site at a high volume. We then want each client to be able to perform reads at their site as well. However we want the data to be available from a write at the sister site in < 50ms. Given that we have plenty of bandwidth. Is there a way to configure redis to meet our needs? our writes maximum size would be on the order of 5k usually much less. The main point is how can i have2 masters that are syncing to one another even if it is not supported by default.

推荐答案

Tom 的答案的关键在于您没有运行任何类型的集群,您只是在向两台服务器写入数据.如果您想确保它们之间的一致性,这是一个问题.考虑当您的客户端无法写入远程服务器时会发生什么.您是否撤消了对本地的写入?当您无法写入远程服务器时,应用程序会发生什么情况?当您无法从本地读取时会发生什么?

The catch with Tom's answer is that you are not running any sort of cluster, you are just writing to two servers. This is a problem if you want to ensure consistency between them. Consider what happens when your client fails a write to the remote server. Do you undo the write to local? What happens to the application when you can't write to the remote server? What happens when you can't read from the local?

第二个问题是 Joshua 提出的基本物理问题.对于往返,您所说的理论最小值为 38 毫秒,而在(三个系统的)两端的理论最大处理时间为 12 毫秒.在这种情况下,我会说期望有点过高,带宽与延迟无关.你可以有一个 10GB 的管道,这些时间仍然存在.也就是说,在 12 毫秒内跨大陆传输 5k 数据也要求很高.您确定您的连接容量可以在 50 毫秒内传输 5k 数据,更不用说 12 毫秒了吗?我一直在整个大陆上使用私有的未使用电路,看到 ping 时间超过 50 毫秒 - 并且 ping 没有传输 5k 数据.

The second catch is the fundamental physics issue Joshua raises. For a round trip you are talking a theoretical minimum of 38ms leaving a theoretical maximum processing time on both ends (of three systems) of 12ms. I'd say that expectation is a bit too much and bandwidth has nothing to do with latency in this case. You could have a 10GB pipe and those timings are still extant. That said, transferring 5k across the continent in 12ms is asking a lot as well. Are you sure you've got the connection capacity to transfer 5k of data in 50ms, let alone 12? I've been on private no-utilization circuits across the continent and seen ping times exceeding 50ms - and ping isn't transferring 5k of data.

您将如何使两个不相关的服务器保持同步?如果您确实需要整个大陆低于 50 毫秒的延迟,那么上述理论上的最佳情况意味着您有 12 毫秒的时间来运行同步算法.即使是检查另一台服务器上的数据的查询也意味着您在 50 毫秒窗口之外.如果数据不同步,您将如何修复?鉴于上述时间,我不知道如何在 50 毫秒内同步.

How will you keep the two unrelated servers in-sync? If you truly need sub-50ms latency across the continent, the above theoretical best-case means you have 12ms to run synchronization algorithms. Even one query to check the data on the other server means you are outside the 50ms window. If the data is out of sync, how will you fix it? Given the above timings, I don't see how it is possible to synchronize in under 50ms.

我建议重新审视基本设计要求.具体来说,为什么有这个要求?跨越大陆的 50 毫秒往返延迟要求通常是营销或缺乏对细节的关注的标志.我敢打赌,如果您分析需求,您会发现这个 50 毫秒的窗口过多且不必要.如果不是,并且数据同步实际上很重要(可能),那么有人将需要确定编写同步代码的大量额外努力是否值得,甚至是否可能保持在 50 毫秒的窗口内.跨大陆延迟低于 50 毫秒的数据同步不是一个简单的问题.

I would recommend revisiting the fundamental design requirements. Specifically, why this requirement? Latency requirements of 50ms round trip across the continent are usually the sign of marketing or lack of attention to detail. I'd wager that if you analyze the requirements you'll find that this 50ms window is excessive and unnecessary. If it isn't, and data synchronization is actually important (likely), than someone will need to determine if the significant extra effort to write synchronization code is worth it or even possible to keep within the 50ms window. Cross-continent sub-50ms latency data sync is not a simple issue.

如果您不需要同步,为什么不简单地运行一台服务器?您可以将大陆另一边的奴隶用于仅用于恢复目的.当然,这仍然意味着最好的情况是您有 12 毫秒的时间来回获取数据.我不会指望50ms 往返操作 + 延迟 + 5k/10k 跨大陆数据传输.

If you have no need for synchronization, why not simply run one server? You could use a slave on the other side of the continent for recovery-only purposes. Of course, that still means that best-case you have 12ms to get the data over there and back. I would not count on 50ms round trip operations+latency+5k/10k data transfer across the continent.

这篇关于Redis 模仿 MASTER/MASTER?或者是其他东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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