Redis 集群在不同主机上有什么好处? [英] What is the benefit of Redis clustering on different hosts?

查看:63
本文介绍了Redis 集群在不同主机上有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有 3 个 Web 应用 A 实例在负载均衡器后面运行(都在不同的机器上).

在多个实例上运行 Redis 是否有好处?如果是这样,您如何在多个 Redis 实例之间实现奇偶校验?

我想我很好奇这种设置的利弊.

出现这个问题的全部原因是,如果您使用多个 Web 应用程序实例,一开始使用 Redis 的一些好处不会被否定吗?在本地机器上与 Redis 交互似乎比从实例 A 的内存中提取数据然后通过网络将其移动到实例 B 要快得多.

解决方案

在多个实例上运行 Redis 是否有好处?

是的.至少有三个好处.

  1. Redis 是单线程的(实际上它有多个线程,但大部分工作是在单个线程中完成的).使用多个实例,您可以获得更好的性能.
  2. Redis 将数据存储在内存中,存储空间受限于单机内存大小.为了存储更多的数据,您可以在不同的机器上部署多个Redis实例,每个实例存储整个数据的不同部分.
  3. 您可以在 2 台不同的机器上运行一个 Redis 主实例及其从属实例.如果运行主实例的机器宕机,从实例仍然可以为请求提供服务.

<块引用>

如果是这样,您如何在多个 Redis 实例之间实现奇偶校验?

我不确定您所说的 parity 是什么意思.你是说主从关系吗?Redis 可以有一个master 和多个slave,每个slave 甚至可以有自己的slave(如果我没记错的话).

<块引用>

如果您使用多个 Web 应用程序实例,那么一开始使用 Redis 的一些好处不会被否定吗?在本地机器上与 Redis 交互似乎比从实例 A 的内存中提取数据然后通过网络将其移动到实例 B 要快得多.

如果您在两台不同的机器上部署 Redis 实例和 Web 应用实例,您必须确保两台机器之间的网络具有低延迟.

Let's say I have 3 instances of web app A running behind a load balancer (all on different machines).

Is there a benefit of running Redis on more than one instance? If so, how do you achieve parity between more than one Redis instance?

I guess I'm curious of the pros/cons with such a setup.

The whole reason this question came up is wouldn't some of the benefits of using Redis in the first place be negated if you use more than one instance of a web app? Interacting with Redis on a local machine seems like it would be much faster than pulling the data from in memory on instance A and then moving it over the network to Instance B.

解决方案

Is there a benefit of running Redis on more than one instance?

Yes. There're at least three benefits.

  1. Redis is single-threaded (in fact, it has more than one thread, but the most work is done in a single thread). With more than one instance, you can achieve better performance.
  2. Redis stores data in memory, and the storage is limited to the size of a single machine's memory. In order to store more data, you can deploy more than one Redis instances on different machines, and each instance stores a different part of the whole data.
  3. You can have a Redis master instance and its slave instance running on 2 different machines. If the machine that running master instance is down, the slave instance can still serves the requests.

If so, how do you achieve parity between more than one Redis instance?

I'm not sure what do you mean by parity. Do you mean master-slave relationship? Redis can have a master with several slaves, and each slave can even has its own slaves (if I remember correctly).

wouldn't some of the benefits of using Redis in the first place be negated if you use more than one instance of a web app? Interacting with Redis on a local machine seems like it would be much faster than pulling the data from in memory on instance A and then moving it over the network to Instance B.

If you deploy Redis instance and the web app instance on 2 different machines, you must make sure that the network between the 2 machines has low latency.

这篇关于Redis 集群在不同主机上有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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