• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
MySQL Multi Master Replication
 

MySQL Multi Master Replication

on

  • 7,748 views

A presentation by Michael Naumov from Wix that was presented at the MySQL Israel User Group

A presentation by Michael Naumov from Wix that was presented at the MySQL Israel User Group

Statistics

Views

Total Views
7,748
Views on SlideShare
6,688
Embed Views
1,060

Actions

Likes
14
Downloads
26
Comments
0

44 Embeds 1,060

http://architects.dzone.com 395
http://top-performance.blogspot.co.il 240
http://top-performance.blogspot.com 125
http://ianmedan.tumblr.com 73
http://top-performance.blogspot.in 27
http://top-performance.blogspot.co.uk 21
http://top-performance.blogspot.ru 19
http://top-performance.blogspot.fr 19
http://top-performance.blogspot.kr 19
http://top-performance.blogspot.de 16
http://top-performance.blogspot.it 11
http://top-performance.blogspot.com.es 8
http://top-performance.blogspot.com.au 7
http://top-performance.blogspot.com.br 7
http://top-performance.blogspot.hk 7
http://top-performance.blogspot.nl 6
http://top-performance.blogspot.ro 5
http://top-performance.blogspot.mx 4
http://top-performance.blogspot.se 4
http://assets.txmblr.com 4
http://top-performance.blogspot.no 4
http://www.tuicool.com 4
http://www.dzone.com 4
http://top-performance.blogspot.ch 3
http://top-performance.blogspot.jp 3
http://top-performance.blogspot.fi 3
http://top-performance.blogspot.com.ar 2
http://top-performance.blogspot.cz 2
http://top-performance.blogspot.ae 2
http://top-performance.blogspot.co.at 2
http://top-performance.blogspot.be 1
https://twitter.com 1
http://top-performance.blogspot.ie 1
http://top-performance.blogspot.hu 1
http://webcache.googleusercontent.com 1
http://localhost 1
http://safe.txmblr.com 1
http://top-performance.blogspot.dk 1
http://plus.url.google.com 1
http://prlog.ru 1
http://top-performance.blogspot.tw 1
http://translate.googleusercontent.com 1
http://top-performance.blogspot.ca 1
http://top-performance.blogspot.pt 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    MySQL Multi Master Replication MySQL Multi Master Replication Presentation Transcript

    • 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