Multi-AZ deployment và Read Replica
Database có thể được replicate để phục vụ hai mục đích khác nhau: duy trì tính sẵn sàng cao khi primary DB instance gặp sự cố, và phân tải đọc; hai mục đích này dùng hai cơ chế khác nhau.
Ghi một đơn hàng, chạy báo cáo, chạy automated backup, sau đó mô phỏng sự cố primary và thử hai loại bảo trì:
Mô phỏng trên là Multi-AZ DB instance deployment (một standby). RDS còn một dạng thứ hai, Multi-AZ DB cluster deployment (RDS for MySQL và RDS for PostgreSQL): một writer và hai reader DB instance ở ba AZ trong cùng Region, sao chép bán đồng bộ (semisynchronous: chỉ cần ít nhất một reader xác nhận), và hai reader vừa là đích failover vừa phục vụ đọc. Các phát biểu “standby không phục vụ đọc” trong bài chỉ áp dụng cho dạng DB instance.
- Multi-AZ DB instance deployment: sao chép đồng bộ sang một standby không phục vụ đọc, nhằm đảm bảo khả năng chịu lỗi; Multi-AZ DB cluster deployment có hai reader ở hai AZ khác, vừa là đích failover vừa phục vụ đọc; failover bằng cách cập nhật CNAME.
- Read Replica: sao chép bất đồng bộ, phục vụ đọc, nhằm giảm tải đọc.
- Bảo trì OS được áp dụng cho standby trước; nâng cấp engine được áp dụng cho cả hai cùng lúc (riêng RDS for SQL Server dùng rolling upgrade).
- Automated backup và snapshot lấy từ standby, nên I/O trên primary không bị tạm dừng.
- Failover Multi-AZ thường mất 60–120 giây.
Multi-AZ deployments and Read Replicas
A database can be replicated for two different purposes: maintaining high availability when the primary DB instance fails, and offloading read traffic; each purpose uses a different mechanism.
Write an order, run a report, run an automated backup, then simulate a primary failure and try the two kinds of maintenance:
The simulation above is a Multi-AZ DB instance deployment (one standby). RDS has a second form, the Multi-AZ DB cluster deployment (RDS for MySQL and RDS for PostgreSQL): one writer and two reader DB instances in three AZs of the same Region, with semisynchronous replication (acknowledgment from at least one reader), and the two readers are both failover targets and serve read traffic. Statements in this lesson that “the standby serves no reads” apply to the DB instance form only.
- Multi-AZ DB instance deployment: synchronous replication to one standby that does not serve reads, for fault tolerance; a Multi-AZ DB cluster deployment has two readers in two other AZs that are failover targets and also serve reads; failover works by updating the CNAME.
- Read Replica: asynchronous replication that serves reads, to offload read traffic.
- OS maintenance is applied to the standby first; engine upgrades are applied to both at the same time (except RDS for SQL Server, which uses a rolling upgrade).
- Automated backups and snapshots are taken from the standby, so I/O on the primary is not suspended.
- A Multi-AZ failover typically takes 60–120 seconds.