In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what is Redis Cluster", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn this article "what is Redis Cluster?"
Redis Cluster is a distributed solution for Redis. When memory, concurrency, traffic and other bottlenecks are encountered, Cluster architecture can be used to achieve load balancing. Because Redis Cluster is available after the Redis3.0 version, before the Redis3.0 version, there are generally two Redis distributed solutions:
The advantage of the client partition scheme is that the partition logic is controllable, and the disadvantage is that it needs to deal with data routing, high availability, failover and other problems.
The advantage of the agent scheme is to simplify the client distributed logic and easy to upgrade and maintain, while the disadvantage is to increase the complexity of architecture deployment and performance loss.
Now that Redis has provided us with a distributed solution, Redis Cluster, let's take a closer look at the functionality of Redis Cluster.
Data distribution
The first problem to be solved in Redis distributed cluster is to map the entire dataset to multiple nodes according to partition rules. So let's introduce the rules of data partitioning. There are two common partition rules: hash partition and sequential partition. The following table shows a comparison of the two partitions.
Looking at the figure above, we know that Redis Cluster uses hash partitioning. So let's focus on the knowledge of hash partition.
There are three main types of hash partitions. Let's introduce the differences between them.
1. Node remainder partition
Using specific data, such as Redis keys or user ID, a hash value is calculated using the formula: hash (key)% N based on the number of nodes, which is used to determine which node the data is mapped to. However, there is a problem with this kind of partition, that is, when the number of nodes changes, such as expanding or reducing nodes, the data node mapping has to be recalculated.
two。 Consistent hash partition
A consistent hash partition assigns a token to each node in the system, and these token form a hash ring. When data reads and writes perform node lookup operations, first calculate the hash value according to key, and then find the first token node that is greater than or equal to the hash value clockwise.
The biggest advantage of this method compared with node surplus is that adding and deleting nodes only affect the adjacent nodes in the hash ring, but have no effect on other nodes. But this kind of zoning also has its disadvantages. Let's take a look at the disadvantages of this partition:
Adding and subtracting nodes will cause part of the data in the hash ring to be missed, which needs to be manually processed or ignored, so consistent hashing is often used to cache scenarios.
When using a small number of nodes, node changes will affect the data mapping in the hash ring on a large scale, so this approach is not suitable for the distributed scheme of a small number of data nodes.
A common consistent hash partition needs to double or subtract half of the nodes to ensure data and load balancing.
3. Virtual slot partition
Virtual slot partition skillfully uses hash space and uses well-dispersed hash functions to map all data to a fixed range of integers, which are defined as slots. This range is generally much larger than the number of nodes. Slot is the basic unit of data management and migration in the cluster. Each node is responsible for a certain number of slots. Because Redis Cluser uses virtual slots, let's focus on the data partitioning of Redis.
Redis data partition
Redis Cluser uses a virtual slot partition, and all keys are mapped to 0-16383 integer slots according to the hash function. The calculation formula: slot=CRC16 (key) & 16383. Each node is responsible for maintaining part of the slot and the key value data mapped by the slot.
Characteristics of Redis virtual slot partition:
Decoupling the relationship between data and nodes simplifies the difficulty of node expansion and contraction.
The node itself maintains the mapping relationship of the slot, and there is no need for the client or agent service to maintain the slot partition metadata.
Mapping query between nodes, slots and keys is supported, which is used in scenarios such as data routing and online scaling.
Cluster function limitation
Redis clusters have some functional limitations compared with standalone machines. Let's take a look at the specific limitations:
Support for 1.key bulk operations is limited. For example, mset and mget only support batch operations for key with the same slott value. Key that maps to different slott values is not supported because mset and mget operations may exist on multiple nodes.
Support for 2.key transaction operations is limited. And it only supports the transaction operation of multiple key on the same node, and the transaction function cannot be used when multiple key are distributed on different nodes.
3.key is the minimum granularity of data partition, so a large key-value object such as hash, list and so on cannot be mapped to different nodes.
4. Multiple database spaces are not supported. Redis on a single machine can support 16 databases, while only one database space can be used in cluster mode. That is db 0.
5. The replication structure supports only one layer, and the slave node can only copy the master node, not the tree replication structure.
The above is all the content of this article "what is Redis Cluster?" thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.