当前位置:网站首页>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 ).
边栏推荐
- Roson的Qt之旅#99 QML表格控件-TableView
- 3D semantic segmentation - PVD
- [book club issue 13] +ffmpeg open source project
- 152. Product maximum subarray
- Hcip notes 12 days
- Fastadmin TP installation uses Baidu rich text editor ueeditor
- 一百个用户眼中,就有一百个QQ
- SAP Fiori 的附件处理(Attachment handling)
- 气数已尽!运营 23 年,昔日“国内第一大电商网站”黄了。。。
- Fudan University emba2022 graduation season - graduation does not forget the original intention and glory to embark on the journey again
猜你喜欢
![[target detection] yolov5 Runtong visdrone data set](/img/a6/118e6bbeb254f9d1afd1406d1b0089.png)
[target detection] yolov5 Runtong visdrone data set

免费的低代码开发平台有哪些?

在华为昇腾Ascend910上复现swin_transformer

Fudan University emba2022 graduation season - graduation does not forget the original intention and glory to embark on the journey again

Why 4everland is the best cloud computing platform for Web 3.0

Budget report ppt

152. Product maximum subarray

数据分析与隐私安全成 Web3.0 成败关键因素,企业如何布局?

Enterprise live broadcast: witness focused products, praise and embrace ecology

HCIP笔记十二天
随机推荐
免费的低代码开发平台有哪些?
jenkins的文件参数,可以用来上传文件
多租户软件开发架构
搜狗批量推送软件-搜狗批量推送工具【2022最新】
Don't believe these "rumors" in the process of preparing for the exam!
LVGL 7.11 tileview界面循环切换
一百个用户眼中,就有一百个QQ
【redis】redis安装
[book club issue 13] +ffmpeg video capture function
文字翻译软件-文字批量翻译转换器免费
easyui修改以及datagrid dialog form控件使用
Doget and dopost
【obs】转载:OBS直播严重延迟和卡顿怎么办?
IaaS基础架构云 —— 云网络
虚拟内存管理
Test framework unittest test test suite, results output to file
中国芯片自给率大幅提升,导致外国芯片库存高企而损失惨重,美国芯片可谓捧起石头砸自己的脚...
Fudan University emba2022 graduation season - graduation does not forget the original intention and glory to embark on the journey again
气数已尽!运营 23 年,昔日“国内第一大电商网站”黄了。。。
[cloud co creation] explore how gaussdb helps ICBC create core financial data