Slide 1

Slide 1 text

High Availability MySQL Jui-Nan Lin (؍๿Ӳ)! Apr. 2012!

Slide 2

Slide 2 text

Agenda About Me! Typical Architecture for Websites! Why High Availability for databases?! Degree of High Availability! Approaches to high availability MySQL! Our Choices! Conclusion!

Slide 3

Slide 3 text

About Me Jui-Nan Lin (؍๿Ӳ)! Section Manager of R&D Team, R&D Dept.! Operate MySQL for 4 year in PIXNET! Twitter: @jnlin! LinkedIn: jnlin! Email: [email protected]! !

Slide 4

Slide 4 text

Typical Architecture (for websites)

Slide 5

Slide 5 text

Why High Availability Hardware can fail, something can break ! – We have broken hardware every week in PIXNET! We need maintenance window! – Upgrade Operating System/MySQL server! We don’t want to be called by my boss at 4am.

Slide 6

Slide 6 text

Our Target Fault Tolerant! No SPOF (Single Point of Failure)! Easy to add repaired node back! Data Correctness! Reduce Cost! – Human Resource! – Hardware!

Slide 7

Slide 7 text

Degree of High Availability Down Time! – 90% uptime => 35 days down per year! – 99% uptime => 4 days! – 99.9% uptime => 8 hours! – 99.99% uptime => 50 mins! – 99.999% uptime => 5 mins

Slide 8

Slide 8 text

Approaches to high availability MySQL Replication – Master and Slave! DRBD! Master-to-Master Replication! MySQL Cluster

Slide 9

Slide 9 text

Replication Idea: If master fails, promote one of slaves to master

Slide 10

Slide 10 text

Replication – Concept Master Slave Slave Slave Master Fail Promoted to master Replication Replication Replication

Slide 11

Slide 11 text

Replication – Pros and Cons Pros! – Simple - MySQL feature! Cons! – Data inconsistency! • Incomplete transaction! • Replication delay!

Slide 12

Slide 12 text

DRBD DRBD - Distributed Replicated Block Device! – RAID 1 over the network! Relies on crash safe storage engine and file system! – InnoDB and XFS! http://www.drbd.org/!

Slide 13

Slide 13 text

DRBD – Concept Heartbeat Active Standby Heartbeat Active Fail

Slide 14

Slide 14 text

DRBD – Pros and Cons Pros! – Reliable! – Data Consistency! Cros! – Warm up problem!

Slide 15

Slide 15 text

Master-to-Master Replication Databases to set master to each other.! http://mysql-mmm.org/

Slide 16

Slide 16 text

Master-to-Master Replication – Concept Writer Reader Writer/Reader Fail Replication Monitor Healthy
 Check Healthy
 Check Monitor Healthy
 Check Healthy
 Check

Slide 17

Slide 17 text

Master-to-Master Replication – Pros and Cons Pros! – No “Warm up” Problem! – Better Resource Usage! Cons! – Same as MySQL replication! – Race condition! • Solved by fixed writer node

Slide 18

Slide 18 text

Master-to-Master Replication – Pros and Cons Cons! – Duplicated Key when use auto-increment! • Solved by auto_increment_increment=2 and auto_increment_offset!

Slide 19

Slide 19 text

MySQL Cluster http://www.mysql.com/products/cluster/

Slide 20

Slide 20 text

Failover time Approach Time Replication Fast DRBD Slow Master-to-Master Fast

Slide 21

Slide 21 text

Our Choices DRBD for applications which require more consistency! Master-to-Master Replication for applications which require high performance! Will evaluate cluster configuration in Q4

Slide 22

Slide 22 text

Conclusion Evaluate a suitable solution ! – What degree of high availability do you need?! – What applications do you run?! • Web 2.0 Applications? Billing Data? Mobile Apps?! – How much budget do you have?! Aim for what is reasonable for your needs!