Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle of redis cluster?

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what the principle of redis cluster is. It is very detailed and has certain reference value. Friends who are interested must finish reading it.

Redis is a typical no-sql, that is, non-relational databases store key-value key-value pairs like python dictionaries and work in memory.

Therefore, it is very suitable to act as the cache between all levels of the Internet architecture, such as the 4-layer forwarding layer of lvs and the 7-layer proxy layer of nginx.

In particular, the application layer of lnmp architecture, such as php-fpm or Tomcat to mysql, makes a cache to reduce the pressure on db.

Because a considerable part of the data is only a simple key-value correspondence, and in the actual business often changes rapidly in a short period of time.

If you use storage such as the relational database mysql, it will greatly increase the access to db, resulting in a heavy burden on db because most of all require will eventually converge to db.

So if you want business stability, then solving the pressure of db is the key, so now most of the solutions are to use multi-level no-sql at all levels above the db layer.

Like memcache redis to provide buffering for db

Redis cluster

A Redis cluster is a facility installation that can share data among multiple Redis nodes.

Redis clusters do not support Redis commands that need to process multiple keys at the same time, because executing these commands requires moving data between multiple Redis nodes, and in high load situations, these commands degrade the performance of the Redis cluster and lead to unpredictable behavior.

Redis clusters provide a certain degree of availability availability by partitioning partition: even if some nodes in the cluster fail or are unable to communicate, the cluster can continue to process command requests.

Redis clustering provides the following two benefits:

The ability to automatically split data into multiple nodes by split.

The ability to continue to process command requests when some nodes in the cluster fail or are unable to communicate.

Cluster principle

All redis nodes are interconnected with each other (PING-PONG mechanism), and binary protocols are used internally to optimize transmission speed and bandwidth.

The fail of a node takes effect only when it is detected by more than half of the nodes in the cluster.

The client is directly connected to the redis node and does not require an intermediate proxy layer. The client does not need to connect to all the nodes in the cluster, but to any of the available nodes in the cluster.

Redis-cluster maps all physical nodes to [0-16383] slot, and cluster is responsible for maintaining nodeslotvalue

There are 16384 hash slots built into the Redis cluster. When you need to place a key-value in the Redis cluster, redis first uses the crc16 algorithm to calculate a result for the key, and then calculates the remainder of the result for 16384, so that each key corresponds to a hash slot numbered between 0 and 16383. Redis will map the hash slot to different nodes according to the number of nodes.

These are all the contents of what is the principle of redis clustering. Thank you for reading! Hope to share the content to help you, more related 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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report