SlideShare a Scribd company logo
1 of 43
Download to read offline
PRESENTED BY
History of Redis replication and
future prospects
Zhao Zhao
@solostoy
Alibaba Cloud, senior engineer
• Redis in Alibaba Cloud

• Redis replication history

• Redis replication prospect

• Replication based on AOF

• Multi-active Redis
Standard Ali-Cluster Split-rw
Redis Mode Stand-alone Stand-alone Stand-alone
High Availability Yes Yes Yes
Proxy No Yes Yes
Scalable Up Up & Out Up & Out
Read/Write Splitting No No Yes
Redis in Alibaba Cloud
• Simple architecture

• Easy to use

• High availability

• Full compatibility
VIP
Client
replication
master replica
HA
Standard
• Proxy based cluster

• Easy to use

• High availability

• Good compatibility
VIP
Client
Proxy Proxy Proxy
master
replica
master
replica
master
replica
HA
CS
Ali-Cluster
• Replication chain

• Easy to use

• High availability

• Full compatibility
VIP
Client
Proxy Proxy Proxy
master read-only
replica
read-only
replica
HA
CS
Split-rw
REPLICATION
1. Prepare stage 

• Build connection

2. Full sync stage

• Transfer snapshot(RDB)

3. Incremental sync stage

• Propagate commands
master
replica
replication
replica client
master client
Replication
SYNC
master replica
No.1 Connect to master
No.2 PING to master
No.3 AUTH to master
No.4 Send port to master
• Prepare stage
SYNC
master replica
No.1 SYNC to master
No.2 Save RDB
Feed replica client
output buffer
No.3 Send RDB to replica
No.4 Load RDBNo.4 Put replica online
• Full sync stage
SYNC
master replica
Ping replica by configuration
Propagate commands
• Incremental sync stage
SYNC
master replica
replication
• Disadvantages
1. Prepare stage

2. Full sync stage

3. Incremental sync stage
SYNC
PSYNC
• New features
• Run ID 

• Random ID like process ID

• Replication offset

• Record the replication status

• Replication backlog

• Cache the replication data
master
replica
replication
master client: run_id: ABC
reploff: 123
· run_id: ABC
· repl_offset: 123
· run_id: ?
· repl_offset: ?
replication backlog
PSYNC
• Replication information
master replica
PSYNC
master replica
replication
• Handle network failure
PSYNC ABC 123+1
+CONTINUE & 124 ~ 200
PING & commands
REPL slave_repl_offset
• run_id: ABC
• repl_backlog:
• 100 ~ 200
• master client
• run_id: ABC
• reploff: 123
PSYNC
masterreplica
• Disadvantages
replicamaster
• Failover
• run_id doesn’t match

• full resync
run_id: XYZrun_id: ABC
master client is NULL
PSYNC
• Disadvantages
master replica
• Change master
• run_id doesn’t match

• offset doesn’t satisfy consistency

• full resync
replica
• run_id: ABC
• repl_offset: 100
PING every 10s PING every 1s
• run_id: OPQ
• repl_offset: 200
• run_id: ?
• repl_offset: ?
• master.run_id: ABC
• master.reploff: 100
• master.run_id: OPQ
• master.reploff: 200
PSYNC
PSYNC2
• New features
master
replica
replication
master client: repl_id: ABC
reploff: 123
· repl_id: ABC
· repl_offset: 123
· repl_id: ABC
· repl_offset: 123
replication backlog
replication backlog
• Replication ID 

• Same in replication chain

• Replication ID2/offset2

• Record the previous replication ID and offset

• Replica works as a proxy

• Replica just transfer data from master

• Saving replication info in RDB

• RDB contains replication ID and offset
PSYNC2
• Replication information
• master • replica
PSYNC2
master replica
replication
• Resync
PSYNC ABC 123+1
+CONTINUE repl_id & 124 ~ 200
+FULLRESYNC repl_id master_repl_offset
PING & commands
REPL slave_repl_offset
• repl_id: ABC
• repl_backlog:
• 100 ~ 200
• repl_id: ABC
• master client
• repl_id: ABC
• reploff: 123
PSYNC2
repl_id: ABC
repl_offset: 123
repl_id: ABC
repl_offset: 123
• Failover
replicamaster
repl_id: XYZ
repl_id2: ABC
repl_offset2: 124
• master
master.repl_id: ABC
master.reploff: 123
• replica
PSYNC ABC 123+1
+CONTINUE XYZreplid: XYZ
master.repl_id: XYZ
RDB
repl_id: ABC
repl_offset: 123
replica of no one
PSYNC2
• Change master
master replica replica
1. all the replication IDs are same

2. offset satisfies consistency
PING every 1s transfer PING from master
• repl_id: ABC
• repl_offset: 100
• repl_id: ABC
• repl_offset: 100
• repl_id: ABC
• repl_offset: 100
• master.repl_id: ABC
• master.reploff: 100
• master.repl_id: ABC
• master.reploff: 100
PSYNC2
PSYNC3
• Next improvements to Redis replication
https://github.com/antirez/redis/issues/4357
• AOF annotations 

• AOF contains replication infomations

• Detecting reboot instances as failing

• Check run id to failover

• Replica ability to reconnect master with partial sync

• Same as PSYNC2
PSYNC3
AOF-PSYNC
• AOF annotations—oplog
• AOF OPINFO command
OPINFO
Redis Cmd
*2rn$6rnOPINFOrn$16rn***rn
*3rn$3rSETrn$3rnKEYrn$5rnVALUErn
AOF-PSYNC
AOF
*2
$6
OPINFO
$16
***
dbid
opid
timestamp
*3
$3
SET
$3
KEY
$5
VALUE
OPINFO
Redis Command
OPINFO
Redis Command
OPINFO
Redis Command
OPINFO
Redis Command
AOF-PSYNC
master replica
replication
• Resync
PSYNC ABC 123+1 40+1
+AOFCONTINUE repl_id
PING & commands
REPL slave_repl_offset
• repl_id: ABC
• repl_backlog:
• 200 ~ 300
• oplog in AOF:
• 1 ~ 50
• repl_id: ABC
• master client
• repl_id: ABC
• reploff: 123
• current opid: 40
send command from 41 to 50
SYNCREPLOFFSET
AOF-PSYNC
• Avoid AOF rewrite
RDB1 AOF1 AOF2
timeline
RDB2 AOF3 AOF4
AOF-PSYNC
Multi-active
Multi-active
• Improve oplog
Multi-active
AOF
OPINFO
Redis Command
*2
$6
OPINFO
$32
***
server_id
dbid
opid
src_opid
timestamp
*3
$3
SET
$3
KEY
$5
VALUE
OPINFO
Redis Command
OPINFO
Redis Command
OPINFO
Redis Command
Multi-active
• OPGET & OPAPPLY
middle ware
OPGET from A OPAPPLY to B
OPGET from BOPAPPLY to A
• OPGET <server_id> <op_id> <count> 

• Get n commands from op_id with server_id in AOF

• OPAPPLY

• Give this client a special mark
Multi-active
• Avoid cycle
server_id op_id src_opid cmd
A 100 -1 Cmd1
server_id op_id src_opid cmd
B 20 -1 Cmd2
server_id op_id src_opid cmd
A 100 -1 Cmd1
B 101 20 Cmd2
server_id op_id src_opid cmd
A * -1 Cmd1
server_id op_id src_opid cmd
B 19 -1 Cmd1
Multi-active
• Conflict
SET key value1
SET key value2 SET key value3
• Conflict Solution
• Users POV - avoid conflict

• Using different DB

• Keys with different prefix
• CRDT - solve conflict

• Most data structures satisfy

• It’s on the way, but it is not the Silver Bullet
Multi-active
Open Source & Alibaba Cloud
https://github.com/alibaba/ApsaraCache
https://www.alibabacloud.com/product/apsaradb-for-redis
https://github.com/alibaba/RedisShake
• https://github.com/soloestoy

• https://twitter.com/soloestoy6

• zhaozhao.zz@alibaba-inc.com
Contact me
Thank you!
PRESENTED BY

More Related Content

What's hot

Setting up your Multi Engine Environment - Apache Railo and ColdFusion
Setting up your Multi Engine Environment - Apache Railo and ColdFusionSetting up your Multi Engine Environment - Apache Railo and ColdFusion
Setting up your Multi Engine Environment - Apache Railo and ColdFusion
Gavin Pickin
 
PHP7 - The New Engine for old good train
PHP7 - The New Engine for old good trainPHP7 - The New Engine for old good train
PHP7 - The New Engine for old good train
Xinchen Hui
 

What's hot (20)

Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
 
Distributed Automation(2018) - London Test Automation in Devops Meetup
Distributed Automation(2018) - London Test Automation in Devops MeetupDistributed Automation(2018) - London Test Automation in Devops Meetup
Distributed Automation(2018) - London Test Automation in Devops Meetup
 
Testable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and Docker
 
Test driven infrastructure
Test driven infrastructureTest driven infrastructure
Test driven infrastructure
 
Setting up your Multi Engine Environment - Apache Railo and ColdFusion
Setting up your Multi Engine Environment - Apache Railo and ColdFusionSetting up your Multi Engine Environment - Apache Railo and ColdFusion
Setting up your Multi Engine Environment - Apache Railo and ColdFusion
 
Migrating to a bazel based CI system: 6 learnings
Migrating to a bazel based CI system: 6 learnings Migrating to a bazel based CI system: 6 learnings
Migrating to a bazel based CI system: 6 learnings
 
Ansible Configuration Management Tool 소개 및 활용
Ansible Configuration Management Tool 소개 및 활용 Ansible Configuration Management Tool 소개 및 활용
Ansible Configuration Management Tool 소개 및 활용
 
Network Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with AnsibleNetwork Automation (NetDevOps) with Ansible
Network Automation (NetDevOps) with Ansible
 
Docker, Atomic Host and Kubernetes.
Docker, Atomic Host and Kubernetes.Docker, Atomic Host and Kubernetes.
Docker, Atomic Host and Kubernetes.
 
CommandBox at CFCamp 2014
CommandBox at CFCamp 2014CommandBox at CFCamp 2014
CommandBox at CFCamp 2014
 
DevOps in PHP environment
DevOps in PHP environmentDevOps in PHP environment
DevOps in PHP environment
 
Flink Forward Berlin 2018: Edward Alexander Rojas Clavijo - "Deploying a secu...
Flink Forward Berlin 2018: Edward Alexander Rojas Clavijo - "Deploying a secu...Flink Forward Berlin 2018: Edward Alexander Rojas Clavijo - "Deploying a secu...
Flink Forward Berlin 2018: Edward Alexander Rojas Clavijo - "Deploying a secu...
 
CommandBox REPL, CLI, and Package Manager
CommandBox REPL, CLI, and Package ManagerCommandBox REPL, CLI, and Package Manager
CommandBox REPL, CLI, and Package Manager
 
Extending Kubernetes – Admission webhooks
Extending Kubernetes – Admission webhooksExtending Kubernetes – Admission webhooks
Extending Kubernetes – Admission webhooks
 
Cfml features modern_coding
Cfml features modern_codingCfml features modern_coding
Cfml features modern_coding
 
Apache Camel: Jetty Component With Example
Apache Camel: Jetty Component With ExampleApache Camel: Jetty Component With Example
Apache Camel: Jetty Component With Example
 
Pinto+Stratopan+Love
Pinto+Stratopan+LovePinto+Stratopan+Love
Pinto+Stratopan+Love
 
PHP7 - The New Engine for old good train
PHP7 - The New Engine for old good trainPHP7 - The New Engine for old good train
PHP7 - The New Engine for old good train
 
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStackSaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
 
DevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: VagrantDevOps Hackathon - Session 1: Vagrant
DevOps Hackathon - Session 1: Vagrant
 

Similar to History Of Redis Replication And Future Prospects: Zhao Zhao

Deep Dive In To Redis Replication: Vishy Kasar
Deep Dive In To Redis Replication: Vishy KasarDeep Dive In To Redis Replication: Vishy Kasar
Deep Dive In To Redis Replication: Vishy Kasar
Redis Labs
 
AP4R on Developers Summit 2008
AP4R on Developers Summit 2008AP4R on Developers Summit 2008
AP4R on Developers Summit 2008
Kato Kiwamu
 
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdf
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdfCisco Wireless LAN Controller Command Reference, Release 7.4.pdf
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdf
ssusercbaa33
 
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Redis Labs
 
My sql replication advanced techniques presentation
My sql replication advanced techniques presentationMy sql replication advanced techniques presentation
My sql replication advanced techniques presentation
epee
 
WordPress Performance & Scalability
WordPress Performance & ScalabilityWordPress Performance & Scalability
WordPress Performance & Scalability
Joseph Scott
 

Similar to History Of Redis Replication And Future Prospects: Zhao Zhao (20)

Deep Dive In To Redis Replication: Vishy Kasar
Deep Dive In To Redis Replication: Vishy KasarDeep Dive In To Redis Replication: Vishy Kasar
Deep Dive In To Redis Replication: Vishy Kasar
 
AP4R on Developers Summit 2008
AP4R on Developers Summit 2008AP4R on Developers Summit 2008
AP4R on Developers Summit 2008
 
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdf
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdfCisco Wireless LAN Controller Command Reference, Release 7.4.pdf
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdf
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Perforce Administration: Optimization, Scalability, Availability and Reliability
Perforce Administration: Optimization, Scalability, Availability and ReliabilityPerforce Administration: Optimization, Scalability, Availability and Reliability
Perforce Administration: Optimization, Scalability, Availability and Reliability
 
Host Health Monitoring with Docker Run
Host Health Monitoring with Docker RunHost Health Monitoring with Docker Run
Host Health Monitoring with Docker Run
 
Rails Performance
Rails PerformanceRails Performance
Rails Performance
 
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
 
Caching solutions with Redis
Caching solutions   with RedisCaching solutions   with Redis
Caching solutions with Redis
 
VS Debugging Tricks
VS Debugging TricksVS Debugging Tricks
VS Debugging Tricks
 
Seek and Destroy Kafka Under Replication
Seek and Destroy Kafka Under ReplicationSeek and Destroy Kafka Under Replication
Seek and Destroy Kafka Under Replication
 
Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled Cucumbers
 
Using Kafka to scale database replication
Using Kafka to scale database replicationUsing Kafka to scale database replication
Using Kafka to scale database replication
 
My sql replication advanced techniques presentation
My sql replication advanced techniques presentationMy sql replication advanced techniques presentation
My sql replication advanced techniques presentation
 
A Universe From Nothing
A Universe From NothingA Universe From Nothing
A Universe From Nothing
 
Node.js - Advanced Basics
Node.js - Advanced BasicsNode.js - Advanced Basics
Node.js - Advanced Basics
 
DevOps in PHP environment
DevOps in PHP environment DevOps in PHP environment
DevOps in PHP environment
 
Why MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it BackWhy MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it Back
 
Crossing platforms: bringing call of duty to mobile – Unite Copenhagen 2019
Crossing platforms: bringing call of duty to mobile – Unite Copenhagen 2019Crossing platforms: bringing call of duty to mobile – Unite Copenhagen 2019
Crossing platforms: bringing call of duty to mobile – Unite Copenhagen 2019
 
WordPress Performance & Scalability
WordPress Performance & ScalabilityWordPress Performance & Scalability
WordPress Performance & Scalability
 

More from Redis Labs

SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
Redis Labs
 
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 

More from Redis Labs (20)

Redis Day Bangalore 2020 - Session state caching with redis
Redis Day Bangalore 2020 - Session state caching with redisRedis Day Bangalore 2020 - Session state caching with redis
Redis Day Bangalore 2020 - Session state caching with redis
 
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
 
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
 
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
 
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
 
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis for Data Science and Engineering by Dmitry Polyakovsky of OracleRedis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
 
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
 
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
 
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
 
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
 
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
 
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
 
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
 
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
 
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
 
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
 
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
 
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
 
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
 
Redis as a High Scale Swiss Army Knife by Rahul Dagar and Abhishek Gupta of G...
Redis as a High Scale Swiss Army Knife by Rahul Dagar and Abhishek Gupta of G...Redis as a High Scale Swiss Army Knife by Rahul Dagar and Abhishek Gupta of G...
Redis as a High Scale Swiss Army Knife by Rahul Dagar and Abhishek Gupta of G...
 

Recently uploaded

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

History Of Redis Replication And Future Prospects: Zhao Zhao

  • 1. PRESENTED BY History of Redis replication and future prospects Zhao Zhao @solostoy Alibaba Cloud, senior engineer
  • 2. • Redis in Alibaba Cloud • Redis replication history • Redis replication prospect • Replication based on AOF • Multi-active Redis
  • 3. Standard Ali-Cluster Split-rw Redis Mode Stand-alone Stand-alone Stand-alone High Availability Yes Yes Yes Proxy No Yes Yes Scalable Up Up & Out Up & Out Read/Write Splitting No No Yes Redis in Alibaba Cloud
  • 4. • Simple architecture • Easy to use • High availability • Full compatibility VIP Client replication master replica HA Standard
  • 5. • Proxy based cluster • Easy to use • High availability • Good compatibility VIP Client Proxy Proxy Proxy master replica master replica master replica HA CS Ali-Cluster
  • 6. • Replication chain • Easy to use • High availability • Full compatibility VIP Client Proxy Proxy Proxy master read-only replica read-only replica HA CS Split-rw
  • 8. 1. Prepare stage • Build connection 2. Full sync stage • Transfer snapshot(RDB) 3. Incremental sync stage • Propagate commands master replica replication replica client master client Replication
  • 10. master replica No.1 Connect to master No.2 PING to master No.3 AUTH to master No.4 Send port to master • Prepare stage SYNC
  • 11. master replica No.1 SYNC to master No.2 Save RDB Feed replica client output buffer No.3 Send RDB to replica No.4 Load RDBNo.4 Put replica online • Full sync stage SYNC
  • 12. master replica Ping replica by configuration Propagate commands • Incremental sync stage SYNC
  • 13. master replica replication • Disadvantages 1. Prepare stage 2. Full sync stage 3. Incremental sync stage SYNC
  • 14. PSYNC
  • 15. • New features • Run ID • Random ID like process ID • Replication offset • Record the replication status • Replication backlog • Cache the replication data master replica replication master client: run_id: ABC reploff: 123 · run_id: ABC · repl_offset: 123 · run_id: ? · repl_offset: ? replication backlog PSYNC
  • 17. master replica replication • Handle network failure PSYNC ABC 123+1 +CONTINUE & 124 ~ 200 PING & commands REPL slave_repl_offset • run_id: ABC • repl_backlog: • 100 ~ 200 • master client • run_id: ABC • reploff: 123 PSYNC
  • 18. masterreplica • Disadvantages replicamaster • Failover • run_id doesn’t match • full resync run_id: XYZrun_id: ABC master client is NULL PSYNC
  • 19. • Disadvantages master replica • Change master • run_id doesn’t match • offset doesn’t satisfy consistency • full resync replica • run_id: ABC • repl_offset: 100 PING every 10s PING every 1s • run_id: OPQ • repl_offset: 200 • run_id: ? • repl_offset: ? • master.run_id: ABC • master.reploff: 100 • master.run_id: OPQ • master.reploff: 200 PSYNC
  • 21. • New features master replica replication master client: repl_id: ABC reploff: 123 · repl_id: ABC · repl_offset: 123 · repl_id: ABC · repl_offset: 123 replication backlog replication backlog • Replication ID • Same in replication chain • Replication ID2/offset2 • Record the previous replication ID and offset • Replica works as a proxy • Replica just transfer data from master • Saving replication info in RDB • RDB contains replication ID and offset PSYNC2
  • 22. • Replication information • master • replica PSYNC2
  • 23. master replica replication • Resync PSYNC ABC 123+1 +CONTINUE repl_id & 124 ~ 200 +FULLRESYNC repl_id master_repl_offset PING & commands REPL slave_repl_offset • repl_id: ABC • repl_backlog: • 100 ~ 200 • repl_id: ABC • master client • repl_id: ABC • reploff: 123 PSYNC2
  • 24. repl_id: ABC repl_offset: 123 repl_id: ABC repl_offset: 123 • Failover replicamaster repl_id: XYZ repl_id2: ABC repl_offset2: 124 • master master.repl_id: ABC master.reploff: 123 • replica PSYNC ABC 123+1 +CONTINUE XYZreplid: XYZ master.repl_id: XYZ RDB repl_id: ABC repl_offset: 123 replica of no one PSYNC2
  • 25. • Change master master replica replica 1. all the replication IDs are same 2. offset satisfies consistency PING every 1s transfer PING from master • repl_id: ABC • repl_offset: 100 • repl_id: ABC • repl_offset: 100 • repl_id: ABC • repl_offset: 100 • master.repl_id: ABC • master.reploff: 100 • master.repl_id: ABC • master.reploff: 100 PSYNC2
  • 27. • Next improvements to Redis replication https://github.com/antirez/redis/issues/4357 • AOF annotations • AOF contains replication infomations • Detecting reboot instances as failing • Check run id to failover • Replica ability to reconnect master with partial sync • Same as PSYNC2 PSYNC3
  • 29. • AOF annotations—oplog • AOF OPINFO command OPINFO Redis Cmd *2rn$6rnOPINFOrn$16rn***rn *3rn$3rSETrn$3rnKEYrn$5rnVALUErn AOF-PSYNC
  • 31. master replica replication • Resync PSYNC ABC 123+1 40+1 +AOFCONTINUE repl_id PING & commands REPL slave_repl_offset • repl_id: ABC • repl_backlog: • 200 ~ 300 • oplog in AOF: • 1 ~ 50 • repl_id: ABC • master client • repl_id: ABC • reploff: 123 • current opid: 40 send command from 41 to 50 SYNCREPLOFFSET AOF-PSYNC
  • 32. • Avoid AOF rewrite RDB1 AOF1 AOF2 timeline RDB2 AOF3 AOF4 AOF-PSYNC
  • 37. • OPGET & OPAPPLY middle ware OPGET from A OPAPPLY to B OPGET from BOPAPPLY to A • OPGET <server_id> <op_id> <count> • Get n commands from op_id with server_id in AOF • OPAPPLY • Give this client a special mark Multi-active
  • 38. • Avoid cycle server_id op_id src_opid cmd A 100 -1 Cmd1 server_id op_id src_opid cmd B 20 -1 Cmd2 server_id op_id src_opid cmd A 100 -1 Cmd1 B 101 20 Cmd2 server_id op_id src_opid cmd A * -1 Cmd1 server_id op_id src_opid cmd B 19 -1 Cmd1 Multi-active
  • 39. • Conflict SET key value1 SET key value2 SET key value3 • Conflict Solution • Users POV - avoid conflict • Using different DB • Keys with different prefix • CRDT - solve conflict • Most data structures satisfy • It’s on the way, but it is not the Silver Bullet Multi-active
  • 40. Open Source & Alibaba Cloud https://github.com/alibaba/ApsaraCache https://www.alibabacloud.com/product/apsaradb-for-redis https://github.com/alibaba/RedisShake