What is Multi-AZ in RDS: Explanation and Use Cases
AWS RDS means running a database in two separate availability zones to increase availability and fault tolerance. It automatically creates a standby replica in another zone and switches to it if the main database fails.How It Works
Imagine you have a favorite book that you want to keep safe. Instead of keeping it in one room, you keep a copy in another room far away. If a fire happens in the first room, you still have the copy safe in the other room. Multi-AZ in RDS works similarly by keeping a copy of your database in a different physical location called an availability zone.
When you enable Multi-AZ, AWS automatically creates a standby database in another availability zone. This standby is a live copy that stays in sync with the main database. If the main database has a problem like hardware failure or network issues, AWS quickly switches your application to the standby database without manual intervention. This switch helps keep your database available and reduces downtime.
Example
This example shows how to create an RDS instance with Multi-AZ enabled using AWS CLI. It creates a MySQL database with automatic standby in another availability zone.
aws rds create-db-instance \
--db-instance-identifier mydbinstance \
--db-instance-class db.t3.medium \
--engine mysql \
--allocated-storage 20 \
--master-username admin \
--master-user-password MyPassword123 \
--multi-az \
--backup-retention-period 7When to Use
Use Multi-AZ when you want your database to be highly available and resilient to failures without manual recovery steps. It is ideal for production applications where downtime can cause loss of revenue or user trust.
For example, an online store needs its database always available to process orders. If the main database fails, Multi-AZ ensures the standby takes over quickly, so customers don’t experience interruptions.
It is less useful for development or testing environments where occasional downtime is acceptable and cost savings are more important.
Key Points
- Multi-AZ creates a synchronous standby replica in a different availability zone.
- Automatic failover happens without manual intervention.
- Improves database availability and durability.
- Costs more than single-AZ deployments due to extra resources.
- Best for production workloads needing high uptime.