1 / 27

Replication for Availability & Durability with MySQL and Amazon RDS

Replication for Availability & Durability with MySQL and Amazon RDS. Grant McAlister. Overview. Why replicate? What are the options? What are the issues? What do we do. Why Replicate?. Durability Availability Scaling. Durability. Replicate. Location 1. Location 2. Availability.

tanika
Download Presentation

Replication for Availability & Durability with MySQL and Amazon RDS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Replication for Availability & Durability with MySQL and Amazon RDS Grant McAlister

  2. Overview • Why replicate? • What are the options? • What are the issues? • What do we do.

  3. Why Replicate? • Durability • Availability • Scaling

  4. Durability Replicate Location 1 Location 2

  5. Availability • When disaster or failure happens • Read availability from readable replicas • Read/Write availability by promoting a replica • Can be faster than waiting for a reboot • Online DDL operations (create index, alter table) • Make changes on a replica • Failover to it • Requires Logical Replication

  6. Read Scaling R/W Client R/W Client Read Client Read Client Read Client Read Client Replica1 Replica2 Master Replica3

  7. Replication Options • Logical vs. Physical • Synchronous vs. Asynchronous

  8. Logical vs. Physical • Logical • Standard MySQL Replication • Logical statement or transaction is shipped • Non-deterministic? (Statement vs. Mixed vs. Row) • Physical • Shipping the physical block changes • Oracle Dataguard • Filesystem or block layer replication • Physical SAN device replication • Deterministic (physically exactly the same)

  9. Logical Replication insert into person values(‘grant’); commit; Primary Replica Single Threaded Parse Parse Buffer Replication Log Buffer Replication Log Relay Log Recovery Log Recovery Log Data Data

  10. Physical Replication insert into person values(‘grant’); commit; Primary Replica Parse Parse Buffer Replication Log Buffer Replication Log Relay Log Recovery Log Recovery Log Data Data

  11. Synchronous vs. Asynchronous Replication • Synchronous Replication • Write is not committed until it is written on both replicas • Guarantees high durability (almost no data loss) • Higher transaction latency • Pay penalty now (maybe) • Asynchronous Replication • Acknowledged as soon as written to the local storage • Some level of durability (possible data loss) • Can be far behind on shipping • About LOG SHIPPING – NOT APPLY

  12. Asynchronous insert into person values (‘grant’); DURABLE in ONE LOCATION DURABLE in TWO LOCATION commit; ACK ACK Primary Secondary Relay Log Replication Log grant

  13. Synchronous insert into person values (‘grant’); commit; DURABLE in TWO LOCATION ACK ACK Primary Secondary Relay Log Replication Log grant

  14. Performance Max Apply Rate

  15. Read Scaling Challenges • Eventual Consistency • Read to Write Ratio

  16. Eventual Consistency = Replication Lag Writer Reader Primary Replica

  17. Large Commit = Replication Delay 500,000 rows 100,000 rows

  18. Reasons for Replication Lag • Large transactions • Single apply thread on replica • Network problems • Overloaded replica • DON’T ASSUME THE BEST CASE

  19. Read to Write Ratio 2X 1X 3X SCALE Primary Replica1 Replica2 Replica3 Replica4 Reads 90% Reads10% Reads10% Reads10% Reads10% Reads10% Reads10% Reads10% Reads10% Writes10% Writes10% Writes10% Writes10% Reads10% Reads10% Reads10% Reads10% Reads10% Writes10% Reads10% Reads10% Reads10% Reads10% Writes10% Writes10% Reads10% Writes10% Writes10% Reads10% Reads10% Writes10% Reads10% Reads10% Reads10% Reads10% Reads10% Reads10% Reads10% Writes10% Writes10% Writes10% Writes10% Writes10%

  20. Read to Write Ratio - More Writes 1X 2X SCALE Primary Replica1 Replica2 Replica3 Replica4 Reads 80% Reads 20% Reads 20% Reads 20% Reads 20% Writes 20% Writes 20% Writes 20% Writes 20% Reads 20% Reads 20% Reads 20% Writes 20% Reads 20% Writes 20% Writes 20% Writes 20% Writes 20% Writes20%

  21. What is RDS MySQL • Managed Relational Database Service (RDS) • Automated Backups and Point in Time Recovery • Can Scale CPU & Memory up and down • Online storage scaling • User controlled patching • Multi-AZ replication • Read Replicas

  22. RDS MySQL - Replication • Multi-AZ • Synchronous Replication • Across Availability Zones (AZ) for increased durability • Standby is not usable for reads • Automated rebuilding of failed replica • Read Replica • Standard Asynchronous MySQL replication • Readable by default but also writeable • Can have multiple per master

  23. Read Replicas Multi-AZ Deployments Highly Available, Durable, & Scalable MySQL Deployments

  24. Demo of RDS Multi-AZ failover

  25. THANK YOU

More Related