Day 40 – How AWS Creates Multi-Availability Zone(AZ) RDS
📌📌 How AWS Creates Multi-Availability Zone(AZ) RDS 📌📌
✅ Hopefully, after reading this post, you have some pointers on how AWS RDS Multi-AZ works. Remember, AWS RDS is a proprietary product, so all this information is the best of my knowledge, but please mention in the comment section if I am missing something.
✅ Why do we need a Multi-AZ RDS database?
If you run your database in a single AZ, you are at risk of production outage if it undergoes a hardware failure or AZ itself goes down.
✅ How does it work internally?
When you enable multi-AZ for your database instance, AWS will immediately take a snapshot of the primary instance. After the snapshot completes, RDS migrates the snapshot to the secondary availability zone, restores the snapshot to a database instance, then configures standbytion between the primary where the snapshot was taken. The standbytion layer operates between the underlying EBS volumes and the database application. This standbytion is done synchronously, i.e., all changes made to the primary will also be made on the standby instance before the primary considers the operation complete.
NOTE: This post focus on Amazon RDS Multi-AZ configurations for MySQL, MariaDB, PostgreSQL, and Oracle database instances. Amazon RDS for SQL Server and Amazon Aurora uses a different technology stack to provide Multi-AZ capabilities.
🚨 Converting your instance from single AZ to multi-AZ could have a slight performance impact, such as higher I/O latency. So preferably, do it during downtime or when the load is less.
💡Multi-AZ instance can provide us availability and durability but not scalability, i.e., you can’t use it as a standby instance to offload the workload. To offload the workload, you need to use a read standby. So to be clear, there is no database engine running on the multi-AZ standby instance. So the underlying data might be there, so there is no engine for you to interact with until it becomes a primary instance.
✅ What will happen if your primary RDS instance goes down?
⓵ The standby will immediately be promoted to the primary instance without human intervention.
② You don’t need to update the endpoint to our application, as AWS will take care of the DNS record(They have a really low TTL value) update. In some cases, you might need to restart the application.
🔻 Downtime will be roughly 60 seconds as AWS immediately cycles out the old failed primary instance. Downtime may vary as this doesn’t account for the transaction rollback. AWS now supports Amazon RDS Multi-AZ with two readable standbys(downtime of 35 sec) https://aws.amazon.com/rds/features/multi-az/
📝 Multi-AZ setup isn’t going to try to recover in case of poor performance of your primary instance. If you have issues with slowness(query latency/memory utilization/disk queue depth), RDS will not preemptively do anything to resolve your issue. You, as a customer, will be responsible for these issues.
Enabling Multi-AZ for RDS database
- As you can see Multi-az is not enabled for this DB.
- To enable multi-AZ, select the db and click on modify
- Scroll down to the bottom and click on Create a standby instance (recommended for production usage). Click on continue at the bottom of the screen
- If you want to apply these changes immediately, click on Apply immediately and then click on Modify DB instance.
- Your DB instance status should change to Modifying
- Click on the database and then Logs & events, you will see all the events happening behind the scene.
- If you check it after few min, you will see
📕 Further reading