Certopolis

AWS Certified CloudOps Engineer – Associate

RDS Multi-AZ failover: DB instance vs DB cluster

The Amazon RDS User Guide says a Multi-AZ DB instance deployment keeps a synchronous standby in another Availability Zone and switches to it automatically, typically in 60 to 120 seconds. Failover changes the DNS record of the DB instance, so clients must reconnect. A Multi-AZ DB cluster instead has one writer and two readable instances.

What is a Multi-AZ DB instance deployment?

RDS provisions and maintains a standby replica in a different Availability Zone and replicates to it synchronously. The standby gives failover support only. It cannot serve read traffic, and AWS says the option is not a scaling solution for read-only work.

You can convert an existing DB instance by modifying it and choosing the Multi-AZ option. You do not have to create a new instance.

Because replication is synchronous, a Multi-AZ DB instance deployment can have higher write and commit latency than a Single-AZ deployment.

What happens during a failover?

RDS fails over without administrator action when the primary host is unhealthy or unreachable, when its storage fails, during an operating system patch in the maintenance window, after some instance modifications, or when you reboot the instance and choose reboot with failover. Failover typically takes 60 to 120 seconds; large transactions or a long recovery can extend it.

The failover changes the DNS record of the DB instance to point to the standby. Existing connections have to be re-established.

A Java virtual machine caches DNS lookups. On some configurations the default never refreshes an entry until the JVM restarts, so the application keeps using the old address. AWS recommends a JVM TTL of no more than 60 seconds, set through the networkaddress.cache.ttl property.

Do not use the Availability Zone shown in the console or DescribeDBInstances to confirm a failover, because it can take several minutes to update. The Multi-AZ instance failover completed event is the authoritative signal.

How is a Multi-AZ DB cluster different?

A Multi-AZ DB cluster has a writer DB instance and two reader DB instances in three Availability Zones in one Region. The readers are automatic failover targets and also serve read traffic.

Replication is semisynchronous: a change commits once at least one reader acknowledges it. AWS states that Multi-AZ DB clusters typically have lower write latency than Multi-AZ DB instance deployments.

Multi-AZ DB clusters are supported only on certain DB instance classes: db.c6gd, db.m5d, db.m6gd, db.m6id, db.m6idn, db.m8gd, db.r5d, db.r6gd, db.r6id, db.r6idn, db.r8gd and db.x2iedn. They are not the same as Aurora DB clusters.

Where the exam catches people

  • Sending reporting queries to the standby of a Multi-AZ DB instance deployment: that standby cannot serve read traffic.
  • Believing the endpoint changes after failover: the DNS record is repointed, the name stays the same, and clients must reconnect.
  • Blaming RDS when a Java application fails after failover: a JVM that caches DNS without refreshing keeps the old address until it restarts.
  • Believing you must rebuild a Single-AZ instance to add a standby: modifying the instance and choosing Multi-AZ converts it.
  • Choosing a Multi-AZ DB instance deployment to cut commit latency: synchronous replication can raise it; a Multi-AZ DB cluster typically has lower write latency.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. A Java application on Amazon EC2 connects to an Amazon RDS for PostgreSQL Multi-AZ DB instance by its endpoint. During a test, RDS completed a failover in about 90 seconds. A Python reporting tool reconnected on its own, but the Java application kept failing until its servers were restarted an hour later. Which action should the SysOps administrator take to fix this issue?

    Right. In the game that’s Renown for your Reliability and Business Continuity building.

    Not that one: C is right. In the game your Reliability and Business Continuity building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    A JVM keeps a resolved address for as long as its DNS cache TTL allows, and on some configurations that is until the JVM restarts, which matches a fix that arrived only with a restart. Setting networkaddress.cache.ttl to 60 seconds, the most AWS recommends, makes the JVM look the name up again and follow the endpoint to the new primary.

    Written from docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.MultiAZ.Failover.html

  2. A company runs a production Amazon RDS for PostgreSQL DB instance as a Single-AZ deployment. A SysOps administrator must give it a standby in a second Availability Zone that RDS fails over to automatically. Applications must keep using the current DB instance endpoint. Which action should the SysOps administrator take to meet these requirements?

    Right. In the game that’s Renown for your Reliability and Business Continuity building.

    Not that one: C is right. In the game your Reliability and Business Continuity building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Modifying it and selecting the Multi-AZ option converts it in place: RDS provisions a synchronous standby in another Availability Zone and fails over to it automatically, and the applications keep the endpoint they already use.

    Written from docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.MultiAZSingleStandby.html

  3. A company runs Amazon RDS for MySQL as a Multi-AZ DB instance deployment on db.m6gd.2xlarge. Checkout transactions take longer to commit than the business accepts, and the order team wants commit latency reduced. The database must still fail over automatically to a copy in another Availability Zone. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Reliability and Business Continuity building.

    Not that one: D is right. In the game your Reliability and Business Continuity building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    A Multi-AZ DB cluster replicates semisynchronously: a commit needs an acknowledgment from one of its two readers, not completion everywhere, and AWS states that these clusters typically have lower write latency than Multi-AZ DB instance deployments. The readers are also automatic failover targets in other zones, so the failover requirement still holds. db.m6gd is one of the classes a Multi-AZ DB cluster supports.

    Written from docs.aws.amazon.com/AmazonRDS/latest/UserGuide/multi-az-db-clusters-concepts.html

Ask for something