Redis cluster strategy

Redis provides three cluster strategies:

  1. Master-slave mode: The master-slave mode is relatively simple compared to the following two modes. The main library is responsible for reading and writing operations, while the slave library is only responsible for reading. And data consistency is maintained between the master library and the slave library. In this mode, the client can connect to the main library or a certain slave library. If the main library or a certain slave library is down, the client needs to manually modify the ip address to keep the Redis service going. However, this mode is difficult to solve for large-capacity data. It is difficult to expand because the data that the entire cluster can store is limited by the memory capacity of a certain machine.

  1. Sentry mode: Sentry mode can be regarded as an upgrade operation based on the master-slave mode. In this mode, a sentinel node is added on the basis of the master-slave library. If the main library is down, the sentinel node will find out, and then select a library from the slave library as the main library.

In addition, then someone asked what if the sentinel node is also broken?

Of course, sentinel nodes can be clustered. If a Sentinel node goes down, there are other Sentinel nodes that continue to work. In this mode, a high availability of Redis can be guaranteed. However, it still cannot solve the problem of Redis expansion and the problem of receiving large-capacity data.

  1. Cluster mode: In the current development environment, this mode is relatively common in applications. Because it supports both multi-master and multi-slave, and it will allocate slots according to Key, so that different Keys can be allocated to different master nodes. With the support of this model, Redis perfectly solves the problem of receiving large-capacity data. Of course, the Cluster mode is the same as the Sentinel mode. There are a large number of slave nodes under a master node. Even if the master node goes down, it will not affect the Redis service at all, because it will immediately find a slave node as a backup master node.

To sum up: In actual application development, it can be said that it is handy to choose different modes for development according to different business scenarios. For large-capacity data storage, it is best to choose the Cluster mode as the cluster strategy. If the amount of data requests is not large, the sentinel mode can be selected.

おすすめ

転載: blog.csdn.net/weixin_51220967/article/details/129659608