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