SlideShare a Scribd company logo
MySQL
Multi-Master Replication
Challenge
Michael Naumov
About Wix
1. We provide a platform to build your own and free awesome web site for any device
2. About 40M Registered Users
3. Around 1.3M new registrations every month
4. About 500 employees with 4 offices around the world.
Why do we need Multi-Master topology?
The Vision: Multiple, active DBMS servers with exactly the same data
1. Simple high availability model
2. Operate systems over multiple sites
3. Access geographically “close” data
BUT!
It is not so easy to do as its seems
MySQL consistency in stand alone
install
Transaction #1 Transaction #2
update users update users
set follower=10 set follower=100
where id=101 where id=101
Stop
Consistency in a Distributed environment
Transaction #1 Transaction #2
update users update users
set follower=10 set follower=100
where id=101 where id=101
Communication latency
Transaction #1 In US Transaction #2 in EU
Async replication =
No application latency
SemiSync/Sync replication =
Application latency
CAP Theorem
So what are the solutions out there?
MySQL Native Replication
How Does Native MySQL M/M
Replication Work
Master 1 Master 2
Binlog Binlog
• Statement replication = send client SQL
• Row replication = send changed rows
• Use row replication for multi-master
Row vs. Statement Replication
Auto-Increment Key Offsets
• Set different keys on each server to avoid primary key collisions
[my.cnf]
server-id=1
auto-increment-offset = 1
auto-increment-increment = 4
...
[my.cnf]
server-id=2
auto-increment-offset = 2
auto-increment-increment = 4
...
MySQL Multi-Master Topologies
Master 1
Master 2 Master 3 Master 2
Master 1
Master-master Circular
Replication Replication
MySQLNative Replication Summary
• Built in with well-known capabilities
• MySQL replication by default is asynchronous. In addition to the built-in asynchronous
replication, MySQL 5.5 and above supports semi-synchronous replication.
• Very limited topology support
• Very limited conflict avoidance
• Not a good choice for multi-master if there are
writes to more than 1 master
MySQL Cluster (NDB)
How Does NDB Work?
Access
Layer
Storage
Layer
Mysql Client Mysql Client
NDB1
NDB2NDB4
NDB3
NDB Eventual Consistency Algorithm
• NDB has built-in cross-cluster conflict detection based on epochs and primary keys
• Updates to primary always succeed
• Update on secondary may be rolled back if primary has a conflicting update
• MySQL Cluster resends updates from the primary to “cure” conflicts on the
secondary's clusters
NDB Supported Topologies
NDB
Cluster 2
Secondary
NDB
Cluster 2
Secondary
NDB
Cluster 3
Secondary
NDB
Cluster 1
Primary
Master-master Circular
Replication Replication
NDB
Cluster 1
Primary
MySQLNDB Cluster Summary
• Allows active/active operation on 2 clusters
• Fully synchronous, no action can be returned to client until transactions on all nodes are
really accepted.
• NDB is mainly an in memory database and also if it support table on disk the cost of
them not always make sense.
• Use horizontal partition to equally distribute data cross node, but none of them has the
whole dataset
• Covers failure of individual MySQL nodes inside the cluster by replication factor
• Detects conflicts automatically on rows
Galera
How Does Galera Work?
Galera Replicator
Master 1 Master 2 Master 3
wsrep API* wsrep API wsrep API
wsrep API (write set replication API), defines the interface between Galera replication and the DBMS
Galera approach is Data Centric
• Data does not belong to a node – Node belong to data. Using global transaction Id’s
• Connect to any nodes for writes
• No headache for auto increment. Galera will do it for you
• Galera replicate the full dataset across ALL nodes.
• Galera replicate data synchronously from one node to cluster on the commit, but
apply them on each node by a FIFO queue (multi thread).
Galera Summary
• Galera require InnoDB to work.
• Galera data replication overhead, increase with the number of nodes present in the
cluster.
• Galera do not offers any parallelism between the nodes when retrieving the data;
clients rely on the single node they access.
• Synchronous replication
• Percona XtraDB Cluster is based on Galera
Tungsten
How Does Tungsten Replication Work
Master
Alpha
Master
Bravo
Remote
Bravo
Slave
Tungsten
Replicator Alpha
Tungsten
Replicator Bravo
Local
Alpha
Master
Local
Bravo
Master
Remote
Alpha
Slave
Tungsten Failure Handling
• Replication stops and resumes automatically when network link goes down
• Replication stops on replicator or DBMS failure and recovers after operator restart
• Conflicts can break replication. Auto increment keys should be manually configured
on each node
• Have his own filters for data replication
Tungsten Supported Topologies
All Masters
Star
Snowflake
Tungsten Summary
• Allows active/active operation on N clusters
• Transfer is asynchronous
• Links can be down for days or weeks if required
• It is the application’s responsibility to ensure there are no conflicts
• Tungsten Replicator can replicate data from MySQL to
MongoDB, Oracle, NuoDB, Vertica and others
• Tungsten allows replication from Oracle by using Change Data Capture (CDC).
Destination DBMS can be MySQL or Oracle
Solution Comparison
Native MySQL
(5.6)
MySQL NDB Galera Tungsten
InnoDB + - + +
Asynchronous + - + +
Statement based + + - +
Row Based + - + +
Semi-synchronous + - - -
Synchronous - + + -
Global TRX Id + + + +
Time delay replication + - - +
Thank you all
@NaumovMichael
http://goo.gl/OqaigN

More Related Content

PDF
Routed Fabrics For Ceph
PPT
CCNA SUMMER TRAINNING PPT
PPTX
Basic BGP Configuration
PDF
Demystifying EVPN in the data center: Part 1 in 2 episode series
PDF
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
PDF
Let's trace Linux Lernel with KGDB @ COSCUP 2021
PDF
FlexVPN
Routed Fabrics For Ceph
CCNA SUMMER TRAINNING PPT
Basic BGP Configuration
Demystifying EVPN in the data center: Part 1 in 2 episode series
Simple and Scalable Microservices: Using NATS with Docker Compose and Swarm
Let's trace Linux Lernel with KGDB @ COSCUP 2021
FlexVPN

What's hot (20)

PDF
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
PDF
Intel dpdk Tutorial
PDF
TRex Traffic Generator - Hanoch Haim
PDF
Packet Tracer Simulation Lab Layer 2 Switching
PDF
VLAN and its implementation
PDF
Linux Networking Explained
PPT
Timing wheels
PPTX
Building a Replicated Logging System with Apache Kafka
PDF
[242]open stack neutron dataplane 구현
PPTX
[234] toast cloud open stack sdn 전략-박성우
PPTX
Dynamic ARP Inspection (DAI)
PDF
cisco ccna cheat_sheet
PDF
Introduction to OpenFlow
PDF
Analysis of attacks / vulnerabilities SS7 / Sigtran using Wireshark (and / or...
PDF
PDF
Asynchronous Processing in Java/JEE/Spring
PDF
오픈스택 멀티노드 설치 후기
PDF
Cisco Live! :: Cisco ASR 9000 Architecture :: BRKARC-2003 | Las Vegas 2017
PDF
VLAN Trunking Protocol
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
Intel dpdk Tutorial
TRex Traffic Generator - Hanoch Haim
Packet Tracer Simulation Lab Layer 2 Switching
VLAN and its implementation
Linux Networking Explained
Timing wheels
Building a Replicated Logging System with Apache Kafka
[242]open stack neutron dataplane 구현
[234] toast cloud open stack sdn 전략-박성우
Dynamic ARP Inspection (DAI)
cisco ccna cheat_sheet
Introduction to OpenFlow
Analysis of attacks / vulnerabilities SS7 / Sigtran using Wireshark (and / or...
Asynchronous Processing in Java/JEE/Spring
오픈스택 멀티노드 설치 후기
Cisco Live! :: Cisco ASR 9000 Architecture :: BRKARC-2003 | Las Vegas 2017
VLAN Trunking Protocol
Ad

Viewers also liked (6)

PDF
Geographically Distributed Multi-Master MySQL Clusters
PDF
Multi-master, multi-region MySQL deployment in Amazon AWS
PDF
Galera cluster for MySQL - Introduction Slides
PDF
Geographically Distributed Multi-Master MySQL Clusters
PDF
Tungsten University: MySQL Multi-Master Operations Made Simple With Tungsten ...
PDF
MySQL Multi-Source Replication for PL2016
Geographically Distributed Multi-Master MySQL Clusters
Multi-master, multi-region MySQL deployment in Amazon AWS
Galera cluster for MySQL - Introduction Slides
Geographically Distributed Multi-Master MySQL Clusters
Tungsten University: MySQL Multi-Master Operations Made Simple With Tungsten ...
MySQL Multi-Source Replication for PL2016
Ad

Similar to MySQL Multi Master Replication (20)

ODP
MySQL 5.7 clustering: The developer perspective
PDF
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera Cluster
PDF
Webinar Slides: Geo-Distributed MySQL Clustering Done Right!
PDF
Training Slides: 101 - Basics: Tungsten Clustering - Under The Hood
PDF
OpenStack Days East -- MySQL Options in OpenStack
PPTX
MySQL Options in OpenStack
PDF
The MySQL High Availability Landscape and where Galera Cluster fits in
PDF
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #5: Oracle’s InnoDB Cluster
PDF
Continuent Tungsten Value Proposition Webinar
ODP
MySQL 5.7 Fabric: Introduction to High Availability and Sharding
PDF
Talon systems - Distributed multi master replication strategy
PDF
MariaDB Galera Cluster - Simple, Transparent, Highly Available
DOCX
Master master vs master-slave database
PDF
Massively sharded my sql at tumblr presentation
PDF
Best Practice for Achieving High Availability in MariaDB
PDF
MariaDB Galera Cluster webinar — 2025 Edition.pdf
PPTX
Redis Clustering Advanced___31Mar2025.pptx
PDF
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #4: MS Azure Database MySQL
PDF
Oss4b - pxc introduction
PDF
Webinar Slides: MySQL Multi-Site Multi-Master Done Right
MySQL 5.7 clustering: The developer perspective
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera Cluster
Webinar Slides: Geo-Distributed MySQL Clustering Done Right!
Training Slides: 101 - Basics: Tungsten Clustering - Under The Hood
OpenStack Days East -- MySQL Options in OpenStack
MySQL Options in OpenStack
The MySQL High Availability Landscape and where Galera Cluster fits in
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #5: Oracle’s InnoDB Cluster
Continuent Tungsten Value Proposition Webinar
MySQL 5.7 Fabric: Introduction to High Availability and Sharding
Talon systems - Distributed multi master replication strategy
MariaDB Galera Cluster - Simple, Transparent, Highly Available
Master master vs master-slave database
Massively sharded my sql at tumblr presentation
Best Practice for Achieving High Availability in MariaDB
MariaDB Galera Cluster webinar — 2025 Edition.pdf
Redis Clustering Advanced___31Mar2025.pptx
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #4: MS Azure Database MySQL
Oss4b - pxc introduction
Webinar Slides: MySQL Multi-Site Multi-Master Done Right

More from Moshe Kaplan (20)

PDF
Spark and C Integration
PDF
Introduction to Big Data
PDF
Introduciton to Python
PDF
Creating Big Data: Methodology
PDF
Git Tutorial
PDF
Redis training for java software engineers
PDF
MongoDB training for java software engineers
PDF
MongoDB from Basics to Scale
PPTX
MongoDB Best Practices for Developers
PPTX
The api economy
PPTX
Big Data Workshop
PPT
Scale and Cloud Design Patterns
PPTX
Introduction to MongoDB
PPT
Web systems architecture, Performance and More
PPTX
Do Big Data and NoSQL Fit Your Needs?
PPTX
The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...
PDF
mongoDB Performance
PPT
Web Systems Architecture by Moshe Kaplan
PPTX
Big Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuff
PPT
MySQL crash course by moshe kaplan
Spark and C Integration
Introduction to Big Data
Introduciton to Python
Creating Big Data: Methodology
Git Tutorial
Redis training for java software engineers
MongoDB training for java software engineers
MongoDB from Basics to Scale
MongoDB Best Practices for Developers
The api economy
Big Data Workshop
Scale and Cloud Design Patterns
Introduction to MongoDB
Web systems architecture, Performance and More
Do Big Data and NoSQL Fit Your Needs?
The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...
mongoDB Performance
Web Systems Architecture by Moshe Kaplan
Big Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuff
MySQL crash course by moshe kaplan

Recently uploaded (20)

PDF
Mushroom cultivation and it's methods.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Encapsulation theory and applications.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
Machine Learning_overview_presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Mushroom cultivation and it's methods.pdf
A Presentation on Artificial Intelligence
MIND Revenue Release Quarter 2 2025 Press Release
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
cloud_computing_Infrastucture_as_cloud_p
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Machine learning based COVID-19 study performance prediction
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Programs and apps: productivity, graphics, security and other tools
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Encapsulation theory and applications.pdf
A comparative analysis of optical character recognition models for extracting...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
TLE Review Electricity (Electricity).pptx
Machine Learning_overview_presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
Univ-Connecticut-ChatGPT-Presentaion.pdf
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...

MySQL Multi Master Replication

  • 2. About Wix 1. We provide a platform to build your own and free awesome web site for any device 2. About 40M Registered Users 3. Around 1.3M new registrations every month 4. About 500 employees with 4 offices around the world.
  • 3. Why do we need Multi-Master topology? The Vision: Multiple, active DBMS servers with exactly the same data 1. Simple high availability model 2. Operate systems over multiple sites 3. Access geographically “close” data
  • 4. BUT! It is not so easy to do as its seems
  • 5. MySQL consistency in stand alone install Transaction #1 Transaction #2 update users update users set follower=10 set follower=100 where id=101 where id=101 Stop
  • 6. Consistency in a Distributed environment Transaction #1 Transaction #2 update users update users set follower=10 set follower=100 where id=101 where id=101
  • 7. Communication latency Transaction #1 In US Transaction #2 in EU Async replication = No application latency SemiSync/Sync replication = Application latency
  • 9. So what are the solutions out there?
  • 11. How Does Native MySQL M/M Replication Work Master 1 Master 2 Binlog Binlog
  • 12. • Statement replication = send client SQL • Row replication = send changed rows • Use row replication for multi-master Row vs. Statement Replication
  • 13. Auto-Increment Key Offsets • Set different keys on each server to avoid primary key collisions [my.cnf] server-id=1 auto-increment-offset = 1 auto-increment-increment = 4 ... [my.cnf] server-id=2 auto-increment-offset = 2 auto-increment-increment = 4 ...
  • 14. MySQL Multi-Master Topologies Master 1 Master 2 Master 3 Master 2 Master 1 Master-master Circular Replication Replication
  • 15. MySQLNative Replication Summary • Built in with well-known capabilities • MySQL replication by default is asynchronous. In addition to the built-in asynchronous replication, MySQL 5.5 and above supports semi-synchronous replication. • Very limited topology support • Very limited conflict avoidance • Not a good choice for multi-master if there are writes to more than 1 master
  • 17. How Does NDB Work? Access Layer Storage Layer Mysql Client Mysql Client NDB1 NDB2NDB4 NDB3
  • 18. NDB Eventual Consistency Algorithm • NDB has built-in cross-cluster conflict detection based on epochs and primary keys • Updates to primary always succeed • Update on secondary may be rolled back if primary has a conflicting update • MySQL Cluster resends updates from the primary to “cure” conflicts on the secondary's clusters
  • 19. NDB Supported Topologies NDB Cluster 2 Secondary NDB Cluster 2 Secondary NDB Cluster 3 Secondary NDB Cluster 1 Primary Master-master Circular Replication Replication NDB Cluster 1 Primary
  • 20. MySQLNDB Cluster Summary • Allows active/active operation on 2 clusters • Fully synchronous, no action can be returned to client until transactions on all nodes are really accepted. • NDB is mainly an in memory database and also if it support table on disk the cost of them not always make sense. • Use horizontal partition to equally distribute data cross node, but none of them has the whole dataset • Covers failure of individual MySQL nodes inside the cluster by replication factor • Detects conflicts automatically on rows
  • 22. How Does Galera Work? Galera Replicator Master 1 Master 2 Master 3 wsrep API* wsrep API wsrep API wsrep API (write set replication API), defines the interface between Galera replication and the DBMS
  • 23. Galera approach is Data Centric • Data does not belong to a node – Node belong to data. Using global transaction Id’s • Connect to any nodes for writes • No headache for auto increment. Galera will do it for you • Galera replicate the full dataset across ALL nodes. • Galera replicate data synchronously from one node to cluster on the commit, but apply them on each node by a FIFO queue (multi thread).
  • 24. Galera Summary • Galera require InnoDB to work. • Galera data replication overhead, increase with the number of nodes present in the cluster. • Galera do not offers any parallelism between the nodes when retrieving the data; clients rely on the single node they access. • Synchronous replication • Percona XtraDB Cluster is based on Galera
  • 26. How Does Tungsten Replication Work Master Alpha Master Bravo Remote Bravo Slave Tungsten Replicator Alpha Tungsten Replicator Bravo Local Alpha Master Local Bravo Master Remote Alpha Slave
  • 27. Tungsten Failure Handling • Replication stops and resumes automatically when network link goes down • Replication stops on replicator or DBMS failure and recovers after operator restart • Conflicts can break replication. Auto increment keys should be manually configured on each node • Have his own filters for data replication
  • 28. Tungsten Supported Topologies All Masters Star Snowflake
  • 29. Tungsten Summary • Allows active/active operation on N clusters • Transfer is asynchronous • Links can be down for days or weeks if required • It is the application’s responsibility to ensure there are no conflicts • Tungsten Replicator can replicate data from MySQL to MongoDB, Oracle, NuoDB, Vertica and others • Tungsten allows replication from Oracle by using Change Data Capture (CDC). Destination DBMS can be MySQL or Oracle
  • 30. Solution Comparison Native MySQL (5.6) MySQL NDB Galera Tungsten InnoDB + - + + Asynchronous + - + + Statement based + + - + Row Based + - + + Semi-synchronous + - - - Synchronous - + + - Global TRX Id + + + + Time delay replication + - - +