当前位置:网站首页>Briefly describe the implementation principle of redis cluster
Briefly describe the implementation principle of redis cluster
2022-07-25 16:52:00 【wwzroom】
sketch redis Implementation principle of cluster
1.Redis Cluster working principle
( Multimaster , The contents stored in each master node are different , Each master node has its own slave node , And MySQL( Every node is the same ) Dissimilarity )
At the sentry sentinel In mechanism , Can solve redis High availability problem , When master After failure, it can automatically change slave Upgrade to master, So as to guarantee redis The normal use of the service , But it can't be solved redis The bottleneck of single machine write , Stand alone redis Write performance is limited by the memory size of a single machine 、 Concurrent number 、 Network card speed and other factors .
In order to solve the bottleneck of single machine performance , Improve Redis performance , You can use distributed cluster solutions
1.1 In the early Redis Distributed cluster deployment scheme :
Client partition : It's up to the client program to decide key Write allocated and written redis node, But the client needs to handle the write allocation itself 、 High availability management and fail over, etc
Agency scheme : Based on three party software implementation redis proxy, The proxy layer where clients connect first , Implemented by the agent layer key Write allocation for , It is relatively simple for the client , However, it is relatively troublesome to increase or decrease the number of cluster management nodes , And the agent itself is a single point and performance bottleneck .
redis 3.0 After the release, we introduced the non central architecture redis cluster Mechanism , In the centreless redis In the cluster , Each node holds the current node data and the entire cluster state , Each node is connected to all other nodes
1.2Redis Cluster The characteristics are as follows
all Redis Node usage (PING Mechanism ) interconnection
Whether a node in the cluster fails , More than half of the nodes in the whole cluster fail to monitor ( Equivalent to a sentry ), It's a real failure
Client does not need proxy You can connect directly to redis, The application needs to be configured with all redis The server IP, Direct sum redis Server communication .
redis cluster Put all the redis node Average maps to 0-16383 Slots (slot) On , Read and write to the specified redisnode Operation on top , So how many redis node amount to redis How many times has concurrency been extended , Every redis node To undertake 16384/N Slots
Redis cluster Pre allocation 16384 individual (slot) Slot position , When need is in redis Write a key -value When , Will use CRC16(key) mod 16384 The value after , It was decided that key Which slot of the value is written to determine which one to write Redis Node , So as to effectively solve the single machine bottleneck .
2.Redis cluster Basic framework
Suppose the three primary nodes are :A, B, C Three nodes , Using the Hashimoto trough (hash slot) How to allocate 16384 individual slot If so, their three nodes undertake slot The interval can be :
node A Cover 0-5460
node B Cover 5461-10922
node C Cover 10923-16383

The client sends a request , Will be able to key Conduct hash(crc16 Algorithm ) operation , The resulting array pair 16384 Take the mold , Remainder is 0-16383 Number between , Three nodes , Just allocate , Each node is assigned a node number , Then store the data according to the node number .
3.Redis cluster Master slave architecture
Redis cluster Although the architecture solves the problem of concurrency , But it introduces a new problem , Every Redis master How to solve the problem of high availability ? That's for everyone master All nodes implement master-slave replication , So as to achieve redis High availability

4. summary
redis cluster Each host has its own ip, The client can communicate directly with redis To communicate , There is no need for an agent , Each host communicates with each other , Judge the viability of the other party and , And switch between master and slave freely , Under normal operation , Multiple master nodes can be used for visitors key -value Make allocation records ,( Through slot allocation , Make a difference key -value Write to different master nodes ), Thus, high concurrency can be achieved .
The following figure shows client access redis The process , The core is redirection ( There is no need for an agent ).
边栏推荐
- Who moved my memory and revealed the secret of 90% reduction in oom crash
- Is the online account opening of Founder futures reliable and safe?
- Chain game development ready-made version chain game system development detailed principle chain game source code delivery
- 链游开发现成版 链游系统开发详细原理 链游源码交付
- Frustrated Internet people desperately knock on the door of Web3
- 免费的低代码开发平台有哪些?
- WPF implements user avatar selector
- Enterprise live broadcast: witness focused products, praise and embrace ecology
- Rebudget: balance efficiency and fairness in market-based multi-core resource allocation by reallocating the budget at run time
- 中国芯片自给率大幅提升,导致外国芯片库存高企而损失惨重,美国芯片可谓捧起石头砸自己的脚...
猜你喜欢

2D 语义分割——DeepLabV3plus 复现

城市燃气安全再拉警钟,如何防患于未“燃”?
![[redis] redis installation](/img/4a/750a0b8ca72ec957987fc34e55992f.png)
[redis] redis installation

博云容器云、DevOps平台斩获可信云“技术最佳实践奖”

【目标检测】TPH-YOLOv5:基于transformer的改进yolov5的无人机目标检测

Test Driven Development (TDD) online practice room | classes open on September 17

mindoc制作思维导图

easyui修改以及datagrid dialog form控件使用

3D semantic segmentation - scribed supervised lidar semantic segmentation

Fudan University emba2022 graduation season - graduation does not forget the original intention and glory to embark on the journey again
随机推荐
链游开发现成版 链游系统开发详细原理 链游源码交付
Rainbond插件扩展:基于Mysql-Exporter监控Mysql
城市燃气安全再拉警钟,如何防患于未“燃”?
【目标检测】YOLOv5跑通VOC2007数据集(修复版)
Homepage portal classification query
2022 latest Beijing Construction welder (construction special operation) simulation question bank and answer analysis
文字翻译软件-文字批量翻译转换器免费
测试框架-unittest-测试套件、结果输出到文件
From digitalization to intelligent operation and maintenance: what are the values and challenges?
【目标检测】YOLOv5跑通VisDrone数据集
HCIP笔记十一天
Test framework unittest command line operation and assertion method
Test framework unittest skip test
WPF implements user avatar selector
2022年最新北京建筑施工焊工(建筑特种作业)模拟题库及答案解析
虚拟内存管理
What is the monthly salary of 10000 in China? The answer reveals the cruel truth of income
ReBudget:通过运行时重新分配预算的方法,在基于市场的多核资源分配中权衡效率与公平性
QT ListView 列表显示组件笔记
[Nanjing University of Aeronautics and Astronautics] information sharing for the first and second examinations of postgraduate entrance examination