• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
MySQL - Scale Out @ CloudParty 2013 Milano Talent Garden
 

MySQL - Scale Out @ CloudParty 2013 Milano Talent Garden

on

  • 743 views

MySQL scalability, from shodow instances to Master/Slave and Master/Master architectures.

MySQL scalability, from shodow instances to Master/Slave and Master/Master architectures.

Statistics

Views

Total Views
743
Views on SlideShare
700
Embed Views
43

Actions

Likes
2
Downloads
10
Comments
0

5 Embeds 43

http://walterdalmut.com 28
http://www.linkedin.com 7
http://lanyrd.com 4
https://www.linkedin.com 3
https://twitter.com 1

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 - Scale Out @ CloudParty 2013 Milano Talent Garden MySQL - Scale Out @ CloudParty 2013 Milano Talent Garden Presentation Transcript

    • How to scale out MySQL databases CloudParty 2013 – Database in Cloud – Milan 27 Sep Walter Dal Mut - @walterdalmut www.corley.it
    • http://www.slideshare.net/ziobrando/ddd-dirty-harry-style CloudParty 2013 - 27 Sep Milan Italy
    • Why we are interested in: Scale-Out databases on the Cloud? CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • We need more resources Single hard drives has limits Network interfaces too And so on... CloudParty 2013 - 27 Sep Milan Italy
    • We are also looking for availability CloudParty 2013 - 27 Sep Milan Italy
    • we want to ensure SERVICE availability and NOT server availability CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy Availability % Downtime per Month 90% 72 Hours 95% 36 Hours 99% 7.2 Hours 99.5% 3.6 Hours 99.8 86.23 Minutes 99.95 21.56 Minutes 99.99 4.32 Minutes
    • Ok, we can start... First of all we have to talk about replication CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • How many kind of replications? CloudParty 2013 - 27 Sep Milan Italy
    • Synchronous Replication CloudParty 2013 - 27 Sep Milan Italy
    • Sync Replica is the process that writes data to the primary and secondary node at the SAME time. It is more expensive and introduce latency that slow down the application because. CloudParty 2013 - 27 Sep Milan Italy
    • Asynchronous Replication CloudParty 2013 - 27 Sep Milan Italy
    • Async Replica Is the process that writes data to the primary and secondary node at different time. Is more simple, a primary node doesn't care about others CloudParty 2013 - 27 Sep Milan Italy
    • Semi-Synchronous Replication CloudParty 2013 - 27 Sep Milan Italy
    • Semi-Sync Replica On the master side, write when at least one slave acknowledges that is has received all events CloudParty 2013 - 27 Sep Milan Italy
    • Which kind of replications can we sort up with MySQL? CloudParty 2013 - 27 Sep Milan Italy
    • ASYNC Master/Slave Replica (Read Replicas) CloudParty 2013 - 27 Sep Milan Italy
    • ASYNC Master/Master Replica (Read/Write replicas) CloudParty 2013 - 27 Sep Milan Italy
    • AlwaysAsync! That means: LAG REPLICATIME CloudParty 2013 - 27 Sep Milan Italy
    • Just this? CloudParty 2013 - 27 Sep Milan Italy
    • Semi-Sync Replicas Starting with MySQL 5.5 Implemented by plugins http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html CloudParty 2013 - 27 Sep Milan Italy
    • A slave indicates that it is semy-sync capable On the master side, write when at least one slave acknowledges that is has received all events If no one slave is available, the master revert to async replication If one slave catches up, the master returns to semi-sync replication CloudParty 2013 - 27 Sep Milan Italy
    • And if I need something SYNC? CloudParty 2013 - 27 Sep Milan Italy
    • Percona XtraDB Cluster MySQL Cluster NDB (internally) CloudParty 2013 - 27 Sep Milan Italy
    • Instead using MySQL Replication we can look for replication of network devices “Distributed Replication Block Device” DRBD http://www.drbd.org/users-guide-8.3/ch-heartbeat.html http://dev.mysql.com/doc/refman/5.0/en/ha-drbd.html CloudParty 2013 - 27 Sep Milan Italy
    • DRBD is essentially a RAID 1 on a network CloudParty 2013 - 27 Sep Milan Italy
    • DRBD has 3 replication modes: A → Async B → Semi Sync C → Sync CloudParty 2013 - 27 Sep Milan Italy
    • global { usage-count no; } common { net { protocol C; } } resource r0 { on drbd01 { device /dev/drbd0; disk /dev/sdb1; address 192.168.0.1:7788; meta-disk internal; } on drbd02 { device /dev/drbd0; disk /dev/sdb1; address 192.168.0.2:7788; meta-disk internal; } } CloudParty 2013 - 27 Sep Milan Italy
    • Exactly like a RAID1 array you cannot query the “second device” It means that: “the device” on a secondary node is not mounted/available CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • DRBD is a RAID on networks your entire system doesn't switch automatically in case of failures. In order to automate the failover switch you can use Peacemaker/Corosync http://dev.mysql.com/doc/refman/5.5/en/ha-drbd.html CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • AWS RDS – Multi AZ CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • Master/Slave – Read Replicas Async Replication CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • Master-Slave: Writes-Reads CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • Capacity left for READS Capacity left for WRITES Master-Slave: Write Intensive CloudParty 2013 - 27 Sep Milan Italy
    • Master/Master – Multi Master Async Replication CloudParty 2013 - 27 Sep Milan Italy
    • A primary node see the secondary node as a slave and vice-versa CloudParty 2013 - 27 Sep Milan Italy
    • Master M1 Slave M1 CloudParty 2013 - 27 Sep Milan Italy
    • Master M1 Slave M2 Slave M1 Master M2 CloudParty 2013 - 27 Sep Milan Italy
    • Super Easy! But, it works? CloudParty 2013 - 27 Sep Milan Italy
    • YES? CloudParty 2013 - 27 Sep Milan Italy
    • Why? CloudParty 2013 - 27 Sep Milan Italy
    • Because of auto increment columns CloudParty 2013 - 27 Sep Milan Italy
    • As a cause of LAG replication time two auto-increment keys conflicts quite immediately in a production environment! CloudParty 2013 - 27 Sep Milan Italy
    • 1 1 2 2 APPLICATION APPLICATIONMASTER 1 MASTER 2 INSERT INSERT Both replica stops immediately on replication (split brain) INSERT INTO table (id) VALUES (2) INSERT INTO table (id) VALUES (2) CloudParty 2013 - 27 Sep Milan Italy
    • Any solution? CloudParty 2013 - 27 Sep Milan Italy
    • Avoid auto-increments columns CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • Work on auto-increment columns CloudParty 2013 - 27 Sep Milan Italy
    • lauto_increment_increment controls the increment between successive AUTO_INCREMENT values. lauto_increment_offset determines the starting point for AUTO_INCREMENT column values. CloudParty 2013 - 27 Sep Milan Italy
    • server-id=1 auto-increment-offset = 1 auto-increment-increment = 4 Produces: 1 5 9 13 17 21 25 server-id=2 auto-increment-offset = 2 auto-increment-increment = 4 Produces: 2 6 10 14 18 22 26 CloudParty 2013 - 27 Sep Milan Italy
    • CloudParty 2013 - 27 Sep Milan Italy
    • Collisions can occurs on all unique indexes User names, emails e unique fields in general causes collisions in a asynchronous replicated database. The application must ensure zero collisions CloudParty 2013 - 27 Sep Milan Italy
    • You have to deal also with inconsistencies CloudParty 2013 - 27 Sep Milan Italy
    • Master Master Application UPDATE users SET email='your.email@me.com' where id=1; UPDATE users SET email='ane@y.com' where id=1; ane@y.com your.email@me.com your.email@me.com ane@y.com CloudParty 2013 - 27 Sep Milan Italy
    • Do we have scale writes? CloudParty 2013 - 27 Sep Milan Italy
    • NO! CloudParty 2013 - 27 Sep Milan Italy
    • Master-Master: Writes-Reads Every write still has to be performed on both masters! CloudParty 2013 - 27 Sep Milan Italy
    • We can use Master/Master for: High Availability (Hot Stand-By) MaintenanceTasks CloudParty 2013 - 27 Sep Milan Italy
    • Thanks for listening Any question? walter.dalmut@corley.it @walterdalmut CloudParty 2013 - 27 Sep Milan Italy