SlideShare a Scribd company logo
1 of 31
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

What's hot

OpenStack: Inside Out
OpenStack: Inside OutOpenStack: Inside Out
OpenStack: Inside Out
Etsuji Nakai
 

What's hot (20)

Disaster Recovery and High Availability with Kafka, SRM and MM2
Disaster Recovery and High Availability with Kafka, SRM and MM2Disaster Recovery and High Availability with Kafka, SRM and MM2
Disaster Recovery and High Availability with Kafka, SRM and MM2
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
Graal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllGraal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them All
 
Getting up to Speed with MirrorMaker 2 (Mickael Maison, IBM & Ryanne Dolan) K...
Getting up to Speed with MirrorMaker 2 (Mickael Maison, IBM & Ryanne Dolan) K...Getting up to Speed with MirrorMaker 2 (Mickael Maison, IBM & Ryanne Dolan) K...
Getting up to Speed with MirrorMaker 2 (Mickael Maison, IBM & Ryanne Dolan) K...
 
JavaScript for ABAP Programmers - 3/7 Syntax
JavaScript for ABAP Programmers - 3/7 SyntaxJavaScript for ABAP Programmers - 3/7 Syntax
JavaScript for ABAP Programmers - 3/7 Syntax
 
Helm - Package Manager for Kubernetes
Helm - Package Manager for KubernetesHelm - Package Manager for Kubernetes
Helm - Package Manager for Kubernetes
 
Uber: Kafka Consumer Proxy
Uber: Kafka Consumer ProxyUber: Kafka Consumer Proxy
Uber: Kafka Consumer Proxy
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
 
Reliability Guarantees for Apache Kafka
Reliability Guarantees for Apache KafkaReliability Guarantees for Apache Kafka
Reliability Guarantees for Apache Kafka
 
Multi-Cluster and Failover for Apache Kafka - Kafka Summit SF 17
Multi-Cluster and Failover for Apache Kafka - Kafka Summit SF 17Multi-Cluster and Failover for Apache Kafka - Kafka Summit SF 17
Multi-Cluster and Failover for Apache Kafka - Kafka Summit SF 17
 
Citus Architecture: Extending Postgres to Build a Distributed Database
Citus Architecture: Extending Postgres to Build a Distributed DatabaseCitus Architecture: Extending Postgres to Build a Distributed Database
Citus Architecture: Extending Postgres to Build a Distributed Database
 
Apache Kafka - Martin Podval
Apache Kafka - Martin PodvalApache Kafka - Martin Podval
Apache Kafka - Martin Podval
 
YugaByte DB Internals - Storage Engine and Transactions
YugaByte DB Internals - Storage Engine and Transactions YugaByte DB Internals - Storage Engine and Transactions
YugaByte DB Internals - Storage Engine and Transactions
 
OpenStack: Inside Out
OpenStack: Inside OutOpenStack: Inside Out
OpenStack: Inside Out
 
Kubernetes Architecture
 Kubernetes Architecture Kubernetes Architecture
Kubernetes Architecture
 
PostgreSQL replication
PostgreSQL replicationPostgreSQL replication
PostgreSQL replication
 
Envoy and Kafka
Envoy and KafkaEnvoy and Kafka
Envoy and Kafka
 
Apache Kafka’s Transactions in the Wild! Developing an exactly-once KafkaSink...
Apache Kafka’s Transactions in the Wild! Developing an exactly-once KafkaSink...Apache Kafka’s Transactions in the Wild! Developing an exactly-once KafkaSink...
Apache Kafka’s Transactions in the Wild! Developing an exactly-once KafkaSink...
 
No data loss pipeline with apache kafka
No data loss pipeline with apache kafkaNo data loss pipeline with apache kafka
No data loss pipeline with apache kafka
 

Viewers also liked

MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016
Wagner Bianchi
 

Viewers also liked (6)

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

Similar to MySQL Multi Master Replication

Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera Cluster
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera ClusterWebinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera Cluster
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera Cluster
Continuent
 
Webinar Slides: Geo-Distributed MySQL Clustering Done Right!
Webinar Slides: Geo-Distributed MySQL Clustering Done Right!Webinar Slides: Geo-Distributed MySQL Clustering Done Right!
Webinar Slides: Geo-Distributed MySQL Clustering Done Right!
Continuent
 
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #5: Oracle’s InnoDB Cluster
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #5: Oracle’s InnoDB ClusterWebinar Slides: MySQL HA/DR/Geo-Scale - High Noon #5: Oracle’s InnoDB Cluster
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #5: Oracle’s InnoDB Cluster
Continuent
 
Continuent Tungsten Value Proposition Webinar
Continuent Tungsten Value Proposition WebinarContinuent Tungsten Value Proposition Webinar
Continuent Tungsten Value Proposition Webinar
Continuent
 
Massively sharded my sql at tumblr presentation
Massively sharded my sql at tumblr presentationMassively sharded my sql at tumblr presentation
Massively sharded my sql at tumblr presentation
kriptonium
 
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #4: MS Azure Database MySQL
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #4: MS Azure Database MySQLWebinar Slides: MySQL HA/DR/Geo-Scale - High Noon #4: MS Azure Database MySQL
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #4: MS Azure Database MySQL
Continuent
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
kuchinskaya
 

Similar to MySQL Multi Master Replication (20)

MySQL 5.7 clustering: The developer perspective
MySQL 5.7 clustering: The developer perspectiveMySQL 5.7 clustering: The developer perspective
MySQL 5.7 clustering: The developer perspective
 
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera Cluster
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera ClusterWebinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera Cluster
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #2: Galera Cluster
 
Webinar Slides: Geo-Distributed MySQL Clustering Done Right!
Webinar Slides: Geo-Distributed MySQL Clustering Done Right!Webinar Slides: Geo-Distributed MySQL Clustering Done Right!
Webinar Slides: Geo-Distributed MySQL Clustering Done Right!
 
Training Slides: 101 - Basics: Tungsten Clustering - Under The Hood
Training Slides: 101 - Basics: Tungsten Clustering - Under The HoodTraining Slides: 101 - Basics: Tungsten Clustering - Under The Hood
Training Slides: 101 - Basics: Tungsten Clustering - Under The Hood
 
OpenStack Days East -- MySQL Options in OpenStack
OpenStack Days East -- MySQL Options in OpenStackOpenStack Days East -- MySQL Options in OpenStack
OpenStack Days East -- MySQL Options in OpenStack
 
MySQL Options in OpenStack
MySQL Options in OpenStackMySQL Options in OpenStack
MySQL Options in OpenStack
 
The MySQL High Availability Landscape and where Galera Cluster fits in
The MySQL High Availability Landscape and where Galera Cluster fits inThe MySQL High Availability Landscape and where Galera Cluster fits in
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
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #5: Oracle’s InnoDB ClusterWebinar Slides: MySQL HA/DR/Geo-Scale - High Noon #5: Oracle’s InnoDB Cluster
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #5: Oracle’s InnoDB Cluster
 
Continuent Tungsten Value Proposition Webinar
Continuent Tungsten Value Proposition WebinarContinuent Tungsten Value Proposition Webinar
Continuent Tungsten Value Proposition Webinar
 
MySQL 5.7 Fabric: Introduction to High Availability and Sharding
MySQL 5.7 Fabric: Introduction to High Availability and Sharding MySQL 5.7 Fabric: Introduction to High Availability and Sharding
MySQL 5.7 Fabric: Introduction to High Availability and Sharding
 
Talon systems - Distributed multi master replication strategy
Talon systems - Distributed multi master replication strategyTalon systems - Distributed multi master replication strategy
Talon systems - Distributed multi master replication strategy
 
MariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Galera Cluster - Simple, Transparent, Highly AvailableMariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Galera Cluster - Simple, Transparent, Highly Available
 
Master master vs master-slave database
Master master vs master-slave databaseMaster master vs master-slave database
Master master vs master-slave database
 
Massively sharded my sql at tumblr presentation
Massively sharded my sql at tumblr presentationMassively sharded my sql at tumblr presentation
Massively sharded my sql at tumblr presentation
 
Best Practice for Achieving High Availability in MariaDB
Best Practice for Achieving High Availability in MariaDBBest Practice for Achieving High Availability in MariaDB
Best Practice for Achieving High Availability in MariaDB
 
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #4: MS Azure Database MySQL
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #4: MS Azure Database MySQLWebinar Slides: MySQL HA/DR/Geo-Scale - High Noon #4: MS Azure Database MySQL
Webinar Slides: MySQL HA/DR/Geo-Scale - High Noon #4: MS Azure Database MySQL
 
Oss4b - pxc introduction
Oss4b   - pxc introductionOss4b   - pxc introduction
Oss4b - pxc introduction
 
Webinar Slides: MySQL Multi-Site Multi-Master Done Right
Webinar Slides: MySQL Multi-Site Multi-Master Done RightWebinar Slides: MySQL Multi-Site Multi-Master Done Right
Webinar Slides: MySQL Multi-Site Multi-Master Done Right
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
 

More from Moshe Kaplan

Web systems architecture, Performance and More
Web systems architecture, Performance and MoreWeb systems architecture, Performance and More
Web systems architecture, Performance and More
Moshe Kaplan
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB Performance
Moshe Kaplan
 

More from Moshe Kaplan (20)

Spark and C Integration
Spark and C IntegrationSpark and C Integration
Spark and C Integration
 
Introduction to Big Data
Introduction to Big DataIntroduction to Big Data
Introduction to Big Data
 
Introduciton to Python
Introduciton to PythonIntroduciton to Python
Introduciton to Python
 
Creating Big Data: Methodology
Creating Big Data: MethodologyCreating Big Data: Methodology
Creating Big Data: Methodology
 
Git Tutorial
Git TutorialGit Tutorial
Git Tutorial
 
Redis training for java software engineers
Redis training for java software engineersRedis training for java software engineers
Redis training for java software engineers
 
MongoDB training for java software engineers
MongoDB training for java software engineersMongoDB training for java software engineers
MongoDB training for java software engineers
 
MongoDB from Basics to Scale
MongoDB from Basics to ScaleMongoDB from Basics to Scale
MongoDB from Basics to Scale
 
MongoDB Best Practices for Developers
MongoDB Best Practices for DevelopersMongoDB Best Practices for Developers
MongoDB Best Practices for Developers
 
The api economy
The api economyThe api economy
The api economy
 
Big Data Workshop
Big Data WorkshopBig Data Workshop
Big Data Workshop
 
Scale and Cloud Design Patterns
Scale and Cloud Design PatternsScale and Cloud Design Patterns
Scale and Cloud Design Patterns
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Web systems architecture, Performance and More
Web systems architecture, Performance and MoreWeb systems architecture, Performance and More
Web systems architecture, Performance and More
 
Do Big Data and NoSQL Fit Your Needs?
Do Big Data and NoSQL Fit Your Needs?Do Big Data and NoSQL Fit Your Needs?
Do Big Data and NoSQL Fit Your Needs?
 
The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...
The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...
The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB Performance
 
Web Systems Architecture by Moshe Kaplan
Web Systems Architecture by Moshe KaplanWeb Systems Architecture by Moshe Kaplan
Web Systems Architecture by Moshe Kaplan
 
Big Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuff
Big Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuffBig Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuff
Big Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuff
 
MySQL crash course by moshe kaplan
MySQL crash course by moshe kaplanMySQL crash course by moshe kaplan
MySQL crash course by moshe kaplan
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

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 + - - +