Skip to content

Primary SAA curriculum

Highly Available RDS App

Evolve a single-database web application so it survives database and Availability Zone failures, reconnects safely, and can recover from bad data.

23 min read

After this, you will understand

How a relational application combines managed failover, backup recovery, and reconnect behavior—and why read scaling is a different requirement.

Article guideprerequisites, mental models, and concepts

Article overview

intermediateCloudCertificationReliability

Three useful mental models

In plain terms

Use a private RDS Multi-AZ deployment for automatic failover, automated backups for recovery, and application retries so the service can reconnect after the writer changes.

Decision pressure

Learners use a read replica as the automatic failover answer, treat a standby as a backup, or forget that active database connections can break during failover.

Exam-ready model

Separate four requirements: Multi-AZ for availability, read replicas for read scale, backups for recovery, and application connection handling for the failover transition.

Think before reading

If Multi-AZ copies a mistaken DELETE to the standby, which RDS feature can return the database to a point before that mistake?

Automated backups and point-in-time recovery create a new database restored to a chosen time within the retention window.

Connected learning

These lessons add useful context to the current core lesson.
  1. 1RDS Multi-AZ vs Read ReplicasAWS Reference
  2. 2Static Site With CloudFront And S3AWS Scenario

Concepts Covered

  • Private RDS placement
  • Database subnet groups
  • Multi-AZ DB instance deployments
  • Synchronous standby replication
  • Automatic database failover
  • RDS endpoint behavior
  • Automated backups and point-in-time recovery
  • Read replicas and replication lag
  • Connection pools, reconnects, and safe retries
  • AWS Solutions Architect Associate exam (SAA-C03) availability and recovery signals

1. Situation

The application already runs on two servers in different Availability Zones (AZs), and a load balancer can send requests to either one. That makes the application tier highly available. The database is still different: both servers depend on one Amazon RDS database instance in one AZ. RDS is AWS's managed relational database service.

The application connects through an RDS endpoint, which is a DNS name such as orders-db.abc123.us-east-1.rds.amazonaws.com. The application uses that stable name instead of hardcoding the database instance's IP address. RDS can later change which database instance the name points to.

The application tier has redundancy, but the single database remains a shared failure point.

The load balancer can route around a failed application instance. The Auto Scaling group can replace unhealthy compute. But every request still depends on one database instance in one Availability Zone.

If that database becomes unavailable, the healthy application servers have nowhere to read or write business data. The web tier is highly available on paper, yet the application is down.

The business now gives four requirements:

  1. Continue after a database instance or Availability Zone failure.
  2. Recover from an accidental deletion or bad deployment.
  3. Scale read traffic if reporting and product queries grow.
  4. Keep the application usable while database connections move to a replacement writer.

These requirements sound similar because each one involves another copy of the data. However, each copy has a different purpose: staying available, serving more reads, recovering old data, or helping the application reconnect.

This study uses the classic RDS Multi-AZ DB instance deployment. It has one primary DB instance, which is the active database that serves reads and writes, and one standby DB instance in another AZ. The standby is kept ready to become the new primary if needed.

RDS copies changes to this standby synchronously, meaning the standby is kept closely aligned with the primary as writes occur. This makes it suitable for managed failover, but the application cannot use this classic standby for reporting queries.

A read replica works differently. It normally receives changes asynchronously, after they occur on the primary. It can serve reads, but it may briefly be behind the primary. That delay is called replication lag.

Architecture overview: Multi-AZ protects availability, backups and PITR recover older data, read replicas add read capacity, and the application reconnects after failover.

2. Naive Design

Naive option 1: one database in one Availability Zone

application -> single-AZ RDS DB instance

This is simple and may be appropriate for development or a workload that can tolerate database downtime. It is not highly available.

If that instance or its AZ becomes unavailable, the application must wait for the database to recover or for an operator to restore it. Adding more application servers does not help because every server still depends on the same unavailable database.

Naive option 2: add a read replica and call it failover

A read replica adds read capacity; promotion and redirecting application traffic remain separate recovery steps.

A read replica is useful for read scaling, but it normally has its own endpoint and may be behind the primary because replication is asynchronous. It does not automatically become the application's writer during a normal DB instance failure.

An operator can promote a read replica, which stops replication and turns it into an independent DB instance. The team must then redirect the application to that instance. Promotion and traffic redirection are separate recovery steps, unlike managed Multi-AZ failover.

That is not the same experience as managed Multi-AZ failover.

Naive option 3: enable Multi-AZ and remove backups

The standby receives the database's current state. If the application drops a table, overwrites a balance, or runs a destructive migration, that bad change can reach the standby too.

A standby protects against the current database becoming unavailable. It does not preserve yesterday's correct data after today's bad change.

Multi-AZ preserves a current replacement database—even when the current state contains a mistake. Backups preserve an earlier recovery point.

Naive option 4: assume connections never break

Even automatic failover causes a short transition. Existing database sessions can break, and transactions that were running may fail. A connection pool is the reusable set of database connections kept by the application. After failover, that pool may still contain connections to the old primary.

RDS can finish promoting the standby while the application continues using broken connections. Database availability and application recovery are therefore related, but they are not the same thing.

3. What Breaks

Follow three failures that need three different responses.

Failure story 1: the primary instance stops responding

At 10:00, the application sends traffic to its usual RDS endpoint. At 10:01, the primary instance becomes unavailable.

In a Single-AZ design, RDS has no prepared standby to promote. The service must wait for the original database to recover or for another recovery action, so the database remains unavailable longer.

This failure needs Multi-AZ: a current standby in another AZ and an automatic way to make it the new primary.

Failure story 2: an operator deletes valid data

At 14:00, a migration mistakenly deletes rows. The database remains healthy and continues accepting queries. Multi-AZ replication faithfully copies the new state.

The database infrastructure is healthy, so failover would not help—the standby contains the same bad deletion. This failure needs historical recovery: a backup from before 14:00.

Failure story 3: the standby is promoted but users still see errors

RDS updates the endpoint so that new connections can reach the promoted standby. Existing TCP connections do not move to that new database. Some requests may fail during the change, and the application's connection pool may continue handing out broken connections to the old primary.

The application must discard broken connections, resolve the endpoint again, and open new connections. Retries should be bounded, meaning limited in number and separated by short waits. Writes need extra care because the database may have committed a transaction even if the application never received the success response.

These stories lead to a useful rule:

Start by identifying the failure: infrastructure availability, historical data recovery, and application recovery require different controls.

4. AWS Architecture

Build the database architecture one responsibility at a time.

Step 1: place RDS in private database subnets

Create a DB subnet group, which is a list of subnets where RDS is allowed to place database resources. Include private database subnets in at least two AZs so RDS has placement options across separate failure locations. A private database subnet has no direct internet route to the database.

The subnet group is configuration, not a network hop. Application traffic does not pass through it; RDS uses it when choosing subnets and private IP addresses for database resources.

For a normal web application, set the database's public accessibility to false. The application servers reach it through private VPC networking; internet users reach the application, not the database port.

The DB subnet group gives RDS placement choices. It is configuration, not a component through which application traffic travels.

The subnet group provides placement options. It does not by itself create a standby or enable failover.

Step 2: enable a Multi-AZ DB instance deployment

For the central scenario, configure RDS with one primary DB instance and one synchronous standby in another Availability Zone.

In the classic Multi-AZ DB instance deployment, the primary serves traffic and the standby is reserved for failover.

During normal operation, the primary serves the application's database traffic. RDS keeps the standby ready for failure, but the standby is not an additional read server in this deployment type. Reporting queries cannot be sent to it.

If RDS detects a failure it supports—such as an unhealthy primary host or loss of connectivity—it automatically promotes the standby. RDS then changes the DNS record for the existing endpoint so that the name points to the new primary.

The important distinction is: the endpoint name stays the same, but the database IP address behind the name can change.

MomentEndpoint used by the applicationDatabase behind the endpointConnection consequence
Normal operationThe configured RDS endpointPrimary in AZ AExisting connections use the current primary.
During failoverThe same RDS endpoint nameDNS is being updatedExisting sessions can fail while the writer changes.
After failoverThe same RDS endpoint namePromoted standby in AZ BThe application resolves the name and opens new connections.

Step 3: add automated backups for recovery

Enable automated backups and choose how many days RDS should retain the recovery history. This retention period determines how far back the team can restore. During that window, point-in-time recovery (PITR) can rebuild the database at a selected restorable time—for example, just before an accidental deletion.

PITR creates a new DB instance from backups and transaction logs. It leaves the current production database unchanged; it does not press a rewind button on the running instance.

PITR creates a new DB instance at the selected restorable time; it does not rewind the running production database.

A manual snapshot is a user-created backup that represents one named point in time. Create one before a risky migration when a clear pre-change checkpoint would help. Also test the restore process: having a backup is useful only if the team knows how to restore, validate, and use it.

Step 4: make the application failover-aware

Give each application instance a connection pool with a maximum size. This is a bounded connection pool: it reuses connections but cannot open an unlimited number. After failover, the pool must remove broken connections and create new ones through the RDS endpoint.

Retry temporary connection failures with backoff, meaning the application waits longer between attempts instead of retrying continuously. Database writes need a safety check. Imagine the database commits CreateOrder, but the connection breaks before the success response reaches the application. Repeating the same write blindly could create the order twice.

Use an idempotency key, unique database constraint, transaction identifier, or a business-specific check to recognize that the write may already have succeeded. The goal is not merely to retry—it is to retry without performing the business action twice.

RDS Proxy is an optional managed service that sits between the application and supported RDS databases. The application connects to the proxy endpoint, and the proxy reuses a smaller pool of database connections. During failover, it can continue accepting connections and redirect them to the new primary, reducing some DNS and connection-management disruption. It does not make unsafe retries safe or replace backups and transaction design.

Step 5: add read capacity only when reads are the bottleneck

Add read replicas only when measurements show that read queries are overloading the primary. The application must deliberately send suitable read-only work—such as reports—to the replica's separate endpoint. Writes still go to the primary.

The application chooses the endpoint. Writes and current reads use the writer; suitable read-only work may use a replica that can lag.

Because replication is asynchronous, the replica can briefly return older data. For example, a user might update an address on the primary and immediately read the old address from the replica. Do not send a read-after-write workflow to a replica unless that temporary staleness is acceptable.

5. Request Or Data Flow

Follow three separate flows: a normal database request, an infrastructure failover, and recovery from bad data.

Lifecycle 1: normal request

The application connects through the endpoint to the current primary; the standby remains a synchronized failover copy and does not serve this request.
  1. A user request reaches an application instance through the load balancer.
  2. The application obtains database credentials from a secure store such as Secrets Manager.
  3. The application connects to the RDS endpoint.
  4. DNS directs that connection to the current primary DB instance.
  5. The primary commits the transaction while RDS synchronously keeps the standby current for failover.
  6. The application returns the result to the user.

Lifecycle 2: database failover

RDS performs database failover. The application still owns connection recovery and safe retry behavior.

RDS is responsible for detecting the database failure, promoting the standby, and updating the endpoint's DNS record. The application is responsible for handling broken connections and retrying safe work.

A long transaction may be rolled back, and requests already in progress may return errors. These errors can be normal during a short failover window. Monitoring should also alert when they continue long enough to suggest that the database or application did not recover.

Lifecycle 3: bad-data recovery

  1. Operators identify the last known good time.
  2. RDS restores to that point as a new DB instance.
  3. The team validates the restored data and application compatibility.
  4. The team decides whether to move the whole application to the restored instance, copy only the missing data, or combine the restored data with valid changes made after the restore time.
  5. If the application moves, the team updates its connection settings, credentials, DNS records, and security-group rules to reach the new instance.

Failover automatically replaces unavailable infrastructure with a current standby. Point-in-time restore creates a separate historical database that the team must validate and deliberately put into use. Cutover is the planned step of moving application traffic to that restored database.

6. Security Controls

Protect the network boundary

Keep RDS in private database subnets and set public accessibility to false for the normal architecture.

Use security-group referencing so the database accepts connections from the application tier rather than from a broad IP range:

Private subnet placement removes the direct internet path; the database security group authorizes the application tier on the database port.

The database security group's inbound rule should use the application security group as its source. In plain terms: “Allow database-port traffic only from resources carrying the application security group.” Avoid allowing 0.0.0.0/0—every IPv4 address—an office IP range added for convenience, or the entire VPC when the application tier can be identified precisely.

Protect the credentials and database identity

Store database credentials in AWS Secrets Manager or another approved secret store. Rotate them according to engine and application requirements.

Two permission systems are involved. IAM controls AWS management actions such as creating, modifying, snapshotting, restoring, or deleting an RDS instance. Database users and database roles control SQL actions inside the engine, such as selecting from or updating a table. Permission to modify RDS does not automatically grant permission to query application tables, or vice versa.

Protect data and administrative actions

Use encryption at rest with AWS Key Management Service (AWS KMS), the AWS service that controls the encryption keys, when required. Use TLS to encrypt data while it travels between the application and database. If a snapshot is encrypted with a KMS key, the identity copying, sharing, or restoring that snapshot also needs permission to use that key.

Protect destructive control-plane actions—AWS API operations that change the RDS resource itself. Examples include deleting the DB instance, shortening backup retention, disabling deletion protection, or making the database publicly reachable.

Enable the database engine logs, audit capabilities, and performance tools that match the workload and compliance needs. Send useful measurements and alarms to Amazon CloudWatch, AWS's monitoring service, so the team can see failures and performance problems.

7. Resilience Controls

A highly available relational application needs several layers because different failures need different controls. Two disaster-recovery terms also appear in this table: recovery time objective (RTO) is the target time for restoring service, while recovery point objective (RPO) is the amount of recent data loss the business can tolerate.

FailurePrimary controlWhat still needs work
DB instance or supported AZ failureMulti-AZ automatic failoverApplication reconnect and retry behavior
Accidental delete or bad migrationAutomated backups, PITR, snapshotsRestore validation and data cutover
Read overloadRead replicas, query tuning, cachingReplica lag and read routing
Connection storm—too many clients connect at onceBounded pooling or RDS ProxyConnection limits, controlled waiting, and monitoring
Entire Region unavailableCross-Region recovery designReplication, routing, RTO, and RPO planning

Multi-AZ protects against supported instance and AZ failures inside one AWS Region. It does not automatically create a database or traffic-switching plan in another Region.

RTO and RPO are business targets, not features that Multi-AZ chooses for you. A cross-Region design must decide how data is copied, how traffic moves, how long recovery may take, and how much recent data could be lost.

Monitor both availability and workload health: RDS events, active connections, CPU, free memory, storage space, storage latency, replica lag, deadlocks, and slow queries. The exact alarms depend on the database engine and application, but the goal is to see both “the database is down” and “the database is alive but overloaded.”

Test failover deliberately, first outside production and later through carefully controlled production exercises. Measure the complete user-visible recovery time. RDS may finish failover before the application's connection pools and retries recover.

Test backup restoration separately. A successful failover test proves that the current standby can take over. It does not prove that the team can restore, validate, and use data from before yesterday's accidental deletion.

8. Performance Controls

Before buying a larger database, inspect the work it is already doing:

  1. Find queries that are slow or run very frequently.
  2. Review indexes and execution plans, which show how the database decided to find and combine the requested rows.
  3. Remove unnecessary database round trips—for example, many small queries that could be one query.
  4. Set a maximum connection-pool size across all application instances.
  5. Use measurements to choose compute, memory, storage, and input/output operations per second (IOPS), which describes how many storage operations the database can perform each second.

Adding application servers can make the database problem worse. Ten servers with connection pools of 100 can attempt 1,000 database connections. Scaling the stateless application tier horizontally does not create more capacity in the single relational writer.

Use read replicas when reads—not writes—are the bottleneck and those reads can tolerate slightly old data. Reporting, analytics, and some product browsing often fit. A workflow that must immediately show a user's latest change usually does not.

Use Amazon ElastiCache when the application repeatedly reads the same popular data. The team must decide how long cached data may be old and how the cache is refreshed or removed after a change. A cache can reduce database load, but the database remains the durable source of truth.

In this study's classic Multi-AZ DB instance deployment, the standby exists for failover and cannot serve application reads. RDS Multi-AZ DB clusters are a different deployment type with readable standby instances, and Aurora has its own writer-and-reader architecture. Identify the deployment type before deciding whether a standby can serve reads.

9. Cost Controls

Each feature adds cost because it solves a different problem:

ChoiceWhat you pay forWhat you gain
Multi-AZ DB instance deploymentStandby capacity and replicated storage behaviorManaged same-Region failover
Read replicaAdditional database instance and storageMore read capacity and a separate read endpoint
Longer backup retention and snapshotsAdditional backup storage when usage exceeds included storageMore recovery history
RDS ProxyManaged proxy capacityConnection reuse and improved connection resilience
Larger instance or provisioned IOPSMore database capacityHigher compute, memory, or storage performance

Single-AZ costs less because no standby capacity is maintained. That saving is not a valid tradeoff when the requirement explicitly says the production database must survive an instance or AZ failure automatically.

A read replica saves no work unless the application sends suitable read queries to it. Confirm that reads are the bottleneck and plan how those reads reach the replica before paying for one.

Choose capacity from measurements, but remember that instance size is only one cost source. Inefficient queries and indexes can force a larger instance. Excess storage, long snapshot retention, RDS Proxy, replicas, and cross-Region copies also add cost.

Aurora may be a better fit for some MySQL- or PostgreSQL-compatible workloads, especially when its cluster architecture or scaling features match the requirements. It is not automatically cheaper or required. Choose between RDS engines and Aurora from compatibility, availability, scaling, operations, and cost—not from the service name alone.

10. Exam Variants

For each exam question, ask: What failed or became overloaded, and what outcome is required? Availability, read scaling, historical recovery, connection control, and cross-Region disaster recovery have different answers.

Requirement signalLikely answerWhy
Automatically continue after an RDS instance or AZ problemRDS Multi-AZRDS maintains a standby in another AZ and manages promotion.
The primary is overloaded by read-heavy trafficRead replicasThey provide separate endpoints and database capacity for suitable reads.
Recover data from before an accidental deletionAutomated backups and PITRThe standby contains the current state; PITR creates a historical copy in a new instance.
Keep the relational database off the internetPrivate DB subnets and security groupsThe application tier connects privately, and its security group is allowed to reach the database port.
Many short-lived connections overwhelm the databaseRDS Proxy or bounded application poolingReusing and limiting connections protects database memory and CPU.
Create a named recovery point before a risky migrationManual DB snapshotThe snapshot records a deliberate pre-change checkpoint that persists until deleted.
Recover a relational database in another RegionCross-Region backup or replica strategyMulti-AZ protects one Region; another Region requires a separate copy and recovery plan.
Use readable standbys with managed Multi-AZ availabilityRDS Multi-AZ DB cluster, where supportedThis is a different architecture from the classic DB instance deployment with one non-readable standby.

Watch for requirements that need more than one answer

Suppose an exam question says:

A production MySQL database must fail over automatically after an Availability Zone failure and must recover to a specific time after an accidental deletion.

The question contains two independent requirements:

infrastructure failure -> Multi-AZ
bad data -> automated backups and PITR

Multi-AZ answers “How does the database stay available after infrastructure failure?” PITR answers “How do we recover older data after a valid but harmful change?” The complete answer needs both.

11. Common Traps

TrapBetter reasoning
"A read replica is the normal automatic failover target."A classic read replica is mainly for read scaling. Promoting it and redirecting the application are separate actions. Multi-AZ provides the managed failover path.
"The Multi-AZ standby can serve reports."The standby in a classic Multi-AZ DB instance deployment is reserved for failover and cannot serve application reads.
"No RDS standby can serve reads."RDS Multi-AZ DB clusters have readable standbys. Always identify whether the question describes a DB instance deployment or a DB cluster deployment.
"Multi-AZ means multi-Region."AZs are isolated locations inside one Region. Multi-AZ does not create a database copy in another Region.
"Multi-AZ replaces backups."The standby copies good and bad changes. Historical recovery still requires automated backups or snapshots.
"PITR rolls the production database backward in place."RDS creates a new restored DB instance and leaves production unchanged. The team must validate the restored instance and move or reconcile data.
"The RDS endpoint guarantees uninterrupted sessions."The endpoint name remains stable, but its destination changes. Existing database connections can still break and must be reopened.
"Retry every failed write immediately."The first write may have committed even when its response was lost. Retry only when an idempotency key, constraint, or business check prevents duplicate work.
"More application instances always improve capacity."Every application instance can open more database connections. Scaling the application tier can overload a database that did not scale with it.
"A private database needs no security-group design."Private routing removes a direct internet path. Security groups still decide exactly which resources may connect to the database port.

Final Mental Model: One-Minute Review

Final Architecture Map

The final diagram shows three copies of database data, but each copy solves a different problem. Read the table first, then follow the arrows in the diagram.

TermExact jobRemember it as
RDS endpointGives the application a stable database name even when the writer behind it changesThe database's published phone number
Primary DB instanceServes the application's normal reads and writesThe active records clerk
Multi-AZ standbyMaintains a synchronous current copy for managed failover in another AZThe prepared relief clerk
Automated backups and PITRRestore historical data into a new DB instance after a bad changeThe database time machine
Read replicaReceives an asynchronous copy for additional read capacityThe reporting clerk
Reconnect and safe retry logicHelps the application recover when failover breaks existing connectionsRedialing carefully after the clerk changes
The standby supports availability, the read replica adds read capacity, and backups recreate historical data. These copies are not interchangeable.

Do not choose a database copy merely because the question says “high availability” or “replication.” Ask what the copy must do. The standby replaces a failed primary, the read replica serves additional reads, and backups recreate older data. None of them removes the application's responsibility to reconnect and retry safely during failover.

Read Amazon RDS for the overall managed database model, including engines, subnet groups, storage, backups, and security.

Read RDS Multi-AZ vs Read Replicas if availability and read scaling still feel like the same requirement.

Read RDS And Aurora Recovery Choices for snapshots, point-in-time recovery, backup replication, and disaster-recovery comparisons.

Read Amazon Aurora when the workload may need Aurora's cluster storage, reader endpoints, replica promotion, or global database options.

Read AWS Secrets Manager for database credential storage and rotation patterns.

Official AWS references:

Finished reading?

Your reading history is saved in this browser so you can continue later.

Recommended Next

Static Site With CloudFront And S3AWS Architecture Scenarios20 min read

This applies the foundation mental models to a real architecture decision instead of a service inventory.

Optional exploration

These links add context, but they do not replace the recommended next lesson.

Arcflow Plus is coming — review drills, research breakdowns, more AI. Get one email at launch.