In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
What does redis cluster mean? I believe that many inexperienced people are at a loss about this, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Introduction to Redis Cluster
A Redis cluster is an assembly that provides data sharing among multiple Redis nodes.
Redis clusters do not support commands to handle multiple keys, because this requires moving data between different nodes, thus not achieving the performance of Redis, which can lead to unpredictable errors under high load.
Redis clusters provide a certain degree of availability through partitioning and continue to process commands when a node is down or unreachable in the real environment. Advantages of Redis clusters:
Automatically split the data to different nodes.
Some nodes in the entire cluster can continue to process commands if they fail or are unreachable.
Data fragmentation of Redis Cluster
Redis cluster does not use consistent hash, but introduces the concept of hash slot.
The Redis cluster has 16384 hash slots, and each key passes the CRC16 check and modulates 16384 to decide which slot to place. Each node of the cluster is responsible for part of the hash slot. For example, if the current cluster has three nodes, then:
Node A contains hash slots 0 to 5500.
Node B contains hash slots 5501 to 11000.
Node C contains hash slots 11001 to 16384.
This structure is easy to add or remove nodes. For example, if I want to add a new node D, I need to get some slots from nodes A, B, C to D. If I want to remove node A, I need to move the slots in A to B and C nodes, and then remove A nodes without any slots from the cluster. Since moving hash slots from one node to another does not stop service, no matter adding, deleting or changing the number of hash slots of a node will not cause the cluster to be unavailable.
Master-Slave replication Model of Redis Cluster
In order to make the cluster still available when some nodes fail or most nodes can not communicate, the cluster uses the master-slave replication model, and each node will have a replica.
In our example, if node B fails in the absence of a replication model, the whole cluster will be unavailable because of the lack of slots in the range of 5501-11000.
However, when the cluster is created (or after a period of time), we add a slave node, A1 Magi B1, C1 for each node, then the whole cluster consists of three master nodes and three slave nodes, so that after node B fails, the cluster will elect B1 to continue to serve the new master node, and the whole cluster will not be unavailable because the slot cannot be found.
However, when both B and B 1 fail, the cluster is not available.
Redis consistency guarantee
Redis does not guarantee strong consistency of data. This means that in practice, the cluster may lose write operations under certain conditions.
The first reason is that the cluster uses asynchronous replication. Write operation process:
The client writes a command to master node B.
Master node B returns the command status to the client.
The master node copies the write operation to him and has to slave nodes B 1, B 2 and B 3.
The copy of the command by the master node occurs after the command reply is returned, because if each command request needs to wait for the copy operation to complete, then the speed at which the master node processes command requests will be greatly reduced-we have to make a tradeoff between performance and consistency. Note: Redis clusters may provide synchronous write methods in the future. Another situation where commands may be lost in a Redis cluster is when a network partition appears in the cluster and a client is isolated from a small number of instances, including at least one master node.
For example, suppose the cluster consists of six nodes A, B, C, A1, B1, and C1, in which A, B, C are master nodes, and A1, B1, and C1 are the subordinate nodes of An and Magi. There is also a client Z1 that assumes that network partitioning occurs in the cluster, then the cluster may be divided into two sides, most of which contain nodes A, C, A1, B1 and C1, while a small part of the cluster contains node B and client Z1.
Z1 can still write to master node B. if the network partition occurs for a short time, the cluster will continue to operate normally. If the partition is long enough for most parties to elect B1 as the new master, then the data written by Z1 to B will be lost.
After reading the above, have you mastered the meaning of redis cluster? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.