Skip to main content

Configuring Amazon RDS and Aurora for Production

Configure RDS Multi-AZ, read replicas, encryption, backups and Aurora Serverless v2, Global Database and cloning for production databases on AWS.

Overview and What You Will Learn

Amazon RDS is a managed service that runs relational databases (PostgreSQL, MySQL, MariaDB, Oracle, SQL Server and Db2) on AWS, and Amazon Aurora is AWS's cloud-built, MySQL- and PostgreSQL-compatible engine. In both, AWS handles provisioning, patching, backups and failover, while you design schemas, control network access and decide who holds credentials. You cannot SSH into the underlying server, which is the trade for not operating it.

By the end of this lab you will be able to:

  • Explain the difference between Multi-AZ (availability) and read replicas (read scaling), and use both
  • Turn on Storage Auto Scaling, encryption, TLS enforcement and IAM database authentication
  • Keep master passwords out of code with Secrets Manager
  • Launch a private, encrypted, Multi-AZ PostgreSQL instance and a read replica with the AWS CLI
  • Recover with automated backups, point-in-time restore and manual snapshots
  • Choose between Aurora provisioned, Aurora Serverless v2, Global Database and cloning
  • Put ElastiCache in front of a database with a cache-aside pattern

Why This Matters in Production

Relational databases hold the data that cannot be wrong: ledger entries, orders, payments and user balances. A payments platform in the style of Razorpay needs transactional integrity across users, merchants and transactions, and a trading platform such as Zerodha needs every write to be atomic and durable. The most expensive mistakes are made before the first incident: no Multi-AZ, a database that ran out of disk, a public endpoint, or reporting queries pointed at the primary. This lab covers the settings that prevent those.

Core Principles

Multi-AZ and read replicas are the most commonly confused pair of features. They solve different problems and are usually used together. A Multi-AZ standby exists to take over when the primary fails, while a read replica exists to serve extra read traffic.

flowchart LR A([Application]) -->|Reads and writes| B[(Primary
AZ a)] B -->|Sync copy| C[(Standby
AZ b)] B -->|Async copy| D[(Read replica)] A -.->|Reports and analytics| D classDef app fill:#8B5CF6,color:#FFFFFF classDef primary fill:#326CE5,color:#FFFFFF classDef standby fill:#475569,color:#FFFFFF classDef replica fill:#10B981,color:#FFFFFF class A app class B primary class C standby class D replica
Multi-AZ Read replica
Goal High availability and automatic failover Scale out reads, offload reporting
Replication Synchronous (instance deployment) Asynchronous, so lag is possible
Serves read traffic No, for the classic one-standby deployment Yes
Failover Automatic, typically 60 to 120 seconds Manual promotion

Two details are often missed. First, RDS also offers a Multi-AZ DB cluster for PostgreSQL and MySQL, with one writer and two readable standbys in three AZs and failover that AWS documents as typically under about 35 seconds. Second, AWS has raised replica limits: RDS for PostgreSQL supports up to 15 read replicas per source instance (check the limits for your engine, because Oracle and SQL Server differ), and Aurora supports up to 15 Aurora Replicas per cluster.

Aurora separates compute from storage. Every instance in the cluster reads and writes one shared cluster volume, which keeps six copies of your data across three Availability Zones. A write needs 4 of the 6 copies, and a read needs 3 of 6, so Aurora tolerates losing an entire AZ for writes and an AZ plus one more copy for reads.

flowchart TD W[Writer endpoint] --> P[Writer instance] R[Reader endpoint] --> R1[Reader 1] R[Reader endpoint] --> R2[Reader 2] P --> S[(Cluster volume
6 copies, 3 AZs)] R1 --> S R2 --> S classDef endpoint fill:#F97316,color:#FFFFFF classDef compute fill:#326CE5,color:#FFFFFF classDef storage fill:#10B981,color:#FFFFFF class W,R endpoint class P,R1,R2 compute class S storage

The writer endpoint always points to the current writer, and the reader endpoint load-balances across readers. After a failover the endpoint names stay the same, so applications do not change configuration.

Aspect RDS (instance) Aurora
Storage copies Primary plus one standby Six copies in three AZs
Storage growth Auto Scaling up to your maximum Grows automatically, no provisioning
Replica lag Seconds are possible Typically tens of milliseconds
Typical failover 60 to 120 seconds (Multi-AZ instance) Around 30 seconds, often less
Replicas Up to 15 (PostgreSQL, MySQL, MariaDB) Up to 15

AWS also publishes performance claims for Aurora over standard MySQL and PostgreSQL. Treat them as upper bounds and benchmark your own workload before choosing an engine on speed alone. Aurora's price relative to RDS depends on instance size and I/O pattern, so compare using the pricing calculator.

Detailed Step-by-Step Practical Lab

How to Launch a Private, Encrypted Multi-AZ RDS Instance

A production RDS instance sits in private subnets, accepts traffic only from the application's security group, is encrypted from creation and keeps its master password in Secrets Manager. Encryption at rest cannot be switched on later, so choose it at creation.

Bash
export AWS_REGION=ap-south-1
VPC_ID=vpc-0a1b2c3d4e5f60718
APP_SG=sg-0123456789abcdef0
RDS_SG=$(aws ec2 create-security-group \
--group-name rds-sg \
--description "PostgreSQL access from app tier" \
--vpc-id "$VPC_ID" \
--query GroupId --output text)
aws ec2 authorize-security-group-ingress \
--group-id "$RDS_SG" \
--protocol tcp --port 5432 \
--source-group "$APP_SG"
# Subnet group: two private subnets in different AZs
aws rds create-db-subnet-group \
--db-subnet-group-name prod-db-subnet-group \
--db-subnet-group-description "Private subnets for production databases" \
--subnet-ids subnet-0a1b2c3d4e5f60001 subnet-0a1b2c3d4e5f60002
Bash
# --manage-master-user-password stores the password in Secrets Manager
# --max-allocated-storage turns on Storage Auto Scaling up to 100 GiB
# --engine-version is omitted, so the current default version is used
aws rds create-db-instance \
--db-instance-identifier devops-prod-db \
--engine postgres \
--db-instance-class db.t3.micro \
--allocated-storage 20 \
--storage-type gp3 \
--max-allocated-storage 100 \
--master-username dbadmin \
--manage-master-user-password \
--storage-encrypted \
--multi-az \
--no-publicly-accessible \
--db-subnet-group-name prod-db-subnet-group \
--vpc-security-group-ids "$RDS_SG" \
--backup-retention-period 7 \
--enable-iam-database-authentication \
--deletion-protection
aws rds wait db-instance-available --db-instance-identifier devops-prod-db
# Endpoint and the secret that holds the master password
aws rds describe-db-instances \
--db-instance-identifier devops-prod-db \
--query 'DBInstances[0].[Endpoint.Address,MasterUserSecret.SecretArn]' \
--output text

Use db.t3.micro only for a lab, and size real workloads from CPU, memory and connection metrics. A Multi-AZ instance doubles the instance cost, which is the price of automatic failover.

Security

Never set public access to yes on a production database. A public endpoint is reachable from the internet and exposed to credential stuffing and any future engine vulnerability. Keep it in private subnets and let only the application security group reach it.

Tip

Turn on Storage Auto Scaling on every production instance from the start. AWS expands storage when free space stays low (it documents the trigger as less than 10 percent free for at least five minutes, and at least six hours since the last change), so a growing table does not turn into an outage.

How to Connect to RDS from EC2 and Create Test Data

Connect from an instance in the same VPC, fetch the password from Secrets Manager at run time, and require TLS.

Bash
# Install a PostgreSQL client (package name varies by version and distribution)
sudo dnf install -y postgresql16
ENDPOINT=devops-prod-db.abc123xyz.ap-south-1.rds.amazonaws.com
SECRET_ARN=arn:aws:secretsmanager:ap-south-1:123456789012:secret:rds-db-secret-AbCdEf
export PGPASSWORD=$(aws secretsmanager get-secret-value \
--secret-id "$SECRET_ARN" \
--query SecretString --output text | jq -r .password)
psql "host=$ENDPOINT dbname=postgres user=dbadmin sslmode=require"
SQL
CREATE TABLE engineers (
id SERIAL PRIMARY KEY,
name VARCHAR(50),
city VARCHAR(50)
);
INSERT INTO engineers (name, city) VALUES
('Rahul Sharma', 'Mumbai'),
('Priya Nair', 'Bengaluru'),
('Arjun Verma', 'Hyderabad');
SELECT * FROM engineers;
How to Create a Read Replica and Offload Reporting

A read replica is created from a snapshot of the source and then kept current with asynchronous replication. Point dashboards and analytics at it, so slow queries stop holding resources on the primary.

Bash
# The source must have automated backups on (retention above 0)
aws rds create-db-instance-read-replica \
--db-instance-identifier devops-prod-db-replica \
--source-db-instance-identifier devops-prod-db \
--db-instance-class db.t3.micro \
--no-publicly-accessible
aws rds wait db-instance-available --db-instance-identifier devops-prod-db-replica
SQL
-- Run on the replica: how far behind is it?
SELECT now() - pg_last_xact_replay_timestamp() AS replication_lag;

Monitor the ReplicaLag metric in CloudWatch as well. A read replica is not a failover target for Multi-AZ. If you need to use it after losing the primary, promote it manually with aws rds promote-read-replica, which makes it a standalone instance and breaks replication.

Common Mistake

Running heavy reports on the primary. A 30-second analytical query holds resources and competes with live transactions. Send reporting and BI tools to a replica endpoint, and keep the primary for application traffic.

How to Encrypt and Secure RDS Connections

Encryption in transit, encryption at rest and credential handling are three separate controls, and each has its own setting.

  • At rest: choose --storage-encrypted at creation. Automated backups, snapshots and replicas inherit it, and an encrypted source can only have encrypted replicas.
  • In transit: require TLS. The setting is engine specific: rds.force_ssl for PostgreSQL and SQL Server, and require_secure_transport for MySQL and MariaDB. Both live in a custom parameter group, because default groups cannot be edited.
  • Credentials: use Secrets Manager (--manage-master-user-password) so no password sits in code or config, and rotate it automatically.
Bash
# Replace postgres17 with the parameter group family that matches your engine version
aws rds create-db-parameter-group \
--db-parameter-group-name prod-postgres-params \
--db-parameter-group-family postgres17 \
--description "Production parameters with forced TLS"
aws rds modify-db-parameter-group \
--db-parameter-group-name prod-postgres-params \
--parameters "ParameterName=rds.force_ssl,ParameterValue=1,ApplyMethod=immediate"
aws rds modify-db-instance \
--db-instance-identifier devops-prod-db \
--db-parameter-group-name prod-postgres-params \
--apply-immediately

IAM database authentication replaces the password with a short-lived token for PostgreSQL, MySQL and MariaDB. The token is valid for 15 minutes and is only needed to open the connection, so already-open connections stay up. Grant the application role the rds-db:connect permission for the database user, and create that user in the database with the IAM role.

Bash
# In the database, once: GRANT rds_iam TO app_user;
TOKEN=$(aws rds generate-db-auth-token \
--hostname "$ENDPOINT" --port 5432 \
--username app_user --region ap-south-1)
PGPASSWORD="$TOKEN" psql "host=$ENDPOINT dbname=postgres user=app_user sslmode=require"

IAM authentication suits workloads that open a modest number of connections. For very high connection rates, use RDS Proxy.

To encrypt an existing unencrypted instance, copy a snapshot with encryption enabled and restore from it:

Bash
aws rds create-db-snapshot \
--db-instance-identifier legacy-db \
--db-snapshot-identifier legacy-db-unencrypted
aws rds copy-db-snapshot \
--source-db-snapshot-identifier legacy-db-unencrypted \
--target-db-snapshot-identifier legacy-db-encrypted \
--kms-key-id alias/aws/rds
aws rds restore-db-instance-from-db-snapshot \
--db-instance-identifier legacy-db-encrypted \
--db-snapshot-identifier legacy-db-encrypted

Then update the application to the new endpoint, verify it, and delete the old instance. Use a short maintenance window, because writes made after the snapshot are not carried over.

How to Protect Data with Backups, Snapshots and Point-in-Time Restore

Automated backups and manual snapshots solve different problems. Automated backups with transaction logs let you restore to any second in the retention window (1 to 35 days). Manual snapshots are kept until you delete them, so they are the safety net before risky changes.

Bash
# Check how far back you can restore
aws rds describe-db-instances \
--db-instance-identifier devops-prod-db \
--query 'DBInstances[0].[BackupRetentionPeriod,LatestRestorableTime]' \
--output text
# Manual snapshot before a risky migration
aws rds create-db-snapshot \
--db-instance-identifier devops-prod-db \
--db-snapshot-identifier devops-prod-db-before-migration
# Point-in-time restore: creates a NEW instance and leaves the original untouched
aws rds restore-db-instance-to-point-in-time \
--source-db-instance-identifier devops-prod-db \
--target-db-instance-identifier devops-prod-db-restore \
--use-latest-restorable-time
  • Setting retention to 0 turns off automated backups and point-in-time restore, and also blocks creating read replicas for most engines
  • Manual snapshots can be copied to another Region and shared with another account. Sharing an encrypted snapshot needs a customer managed KMS key, not the default key
  • For Aurora, backups are continuous and incremental on the cluster volume, and the restore also creates a new cluster
  • Use AWS Backup when you need backup policies, cross-account copies or retention rules across many databases
Remember

A restore never overwrites the original. You get a new instance with a new endpoint, so plan for the application cutover step as part of every restore drill.

How to Create an Aurora Cluster with Serverless v2

Aurora Serverless v2 scales compute in small steps between a minimum and maximum capacity, measured in Aurora Capacity Units (ACUs, about 2 GiB of memory each). Since late 2024 a minimum of 0 ACUs is supported on newer engine versions, so an idle cluster can pause and resume on the first connection. The older Aurora Serverless v1 is deprecated.

Bash
# Cluster: storage layer, encryption and scaling range
aws rds create-db-cluster \
--db-cluster-identifier devops-aurora \
--engine aurora-postgresql \
--master-username dbadmin \
--manage-master-user-password \
--storage-encrypted \
--db-subnet-group-name prod-db-subnet-group \
--vpc-security-group-ids "$RDS_SG" \
--backup-retention-period 7 \
--serverless-v2-scaling-configuration MinCapacity=0.5,MaxCapacity=8
# Writer instance
aws rds create-db-instance \
--db-instance-identifier devops-aurora-writer \
--db-cluster-identifier devops-aurora \
--engine aurora-postgresql \
--db-instance-class db.serverless
# Reader instance for read scaling and fast failover
aws rds create-db-instance \
--db-instance-identifier devops-aurora-reader-1 \
--db-cluster-identifier devops-aurora \
--engine aurora-postgresql \
--db-instance-class db.serverless

Set MinCapacity=0 for development and test clusters to enable auto-pause. For production, keep a nonzero minimum, because a paused database takes time to resume and resumed capacity can start lower than before the pause. Serverless suits unpredictable or intermittent traffic, and steady heavy workloads are often cheaper on provisioned instances.

How to Clone an Aurora Cluster for Staging in Minutes

Aurora cloning uses copy-on-write: the clone shares the source's storage pages and only stores blocks that change afterwards. A clone of a large database is available in minutes, and the source is unaffected.

Bash
aws rds restore-db-cluster-to-point-in-time \
--db-cluster-identifier devops-aurora-clone \
--source-db-cluster-identifier devops-aurora \
--restore-type copy-on-write \
--use-latest-restorable-time
# A clone has no instances yet
aws rds create-db-instance \
--db-instance-identifier devops-aurora-clone-1 \
--db-cluster-identifier devops-aurora-clone \
--engine aurora-postgresql \
--db-instance-class db.serverless

Typical uses are testing a schema migration on production-sized data, reproducing a data bug without touching live data, and load testing. Remember that a clone holds real production data, so apply the same access controls or mask the data first.

How to Plan Cross-Region Disaster Recovery with Aurora Global Database

Aurora Global Database replicates at the storage layer from a primary Region to read-only secondary Regions, with typical lag under one second. AWS documents up to 10 secondary Regions in current documentation (older documentation and some partitions list 5, so confirm for your Region).

Bash
# Turn an existing cluster into the primary of a global database
aws rds create-global-cluster \
--global-cluster-identifier devops-global \
--source-db-cluster-identifier arn:aws:rds:ap-south-1:123456789012:cluster:devops-aurora
# Add a secondary cluster in Singapore (run against that Region)
aws rds create-db-cluster \
--region ap-southeast-1 \
--db-cluster-identifier devops-aurora-sg \
--global-cluster-identifier devops-global \
--engine aurora-postgresql
# Planned move of the primary with no data loss
aws rds switchover-global-cluster \
--global-cluster-identifier devops-global \
--target-db-cluster-identifier arn:aws:rds:ap-southeast-1:123456789012:cluster:devops-aurora-sg

Know the difference between the two operations. A switchover is for a healthy global database and loses no data. A failover is for an outage: how much data you lose depends on the replication lag at that moment, and AWS describes RPO as typically seconds and RTO as in the order of minutes. Do not assume a promotion always completes in under a minute, and rehearse it. Also note that both clusters need compatible engine versions for a managed switchover.

How to Add ElastiCache in Front of RDS with Cache-Aside

A cache serves repeated reads from memory in about a millisecond, so the database sees one query instead of thousands. ElastiCache supports Redis OSS and Valkey. The application must check the cache first and fall back to the database, so this is a code change, not a drop-in setting.

Python
import json
def get_engineer(engineer_id):
key = f"engineer:{engineer_id}"
# 1. Try the cache
cached = cache.get(key)
if cached:
return json.loads(cached)
# 2. Miss: read from the database, then store with a TTL
row = db.fetch_one(
"SELECT id, name, city FROM engineers WHERE id = %s", (engineer_id,)
)
cache.setex(key, 300, json.dumps(row))
return row
  • Always set a TTL, and delete or update the key when the underlying row changes
  • Add small random jitter to TTLs, so a popular set of keys does not expire at the same instant and flood the database
  • Storing user sessions in the cache removes the need for sticky sessions behind a load balancer
How to Clean Up the Lab Resources

Delete replicas first, then the primary. Deletion protection must be turned off before deleting.

Bash
aws rds delete-db-instance --db-instance-identifier devops-prod-db-replica --skip-final-snapshot
aws rds modify-db-instance --db-instance-identifier devops-prod-db --no-deletion-protection --apply-immediately
aws rds delete-db-instance --db-instance-identifier devops-prod-db --skip-final-snapshot --delete-automated-backups
aws rds delete-db-subnet-group --db-subnet-group-name prod-db-subnet-group
aws ec2 delete-security-group --group-id "$RDS_SG"

Never use --skip-final-snapshot on a real database. Take a final snapshot instead.

Production Best Practices & Common Pitfalls

  • Enable Multi-AZ for every production database. Add read replicas separately when reads become the bottleneck.
  • Put databases in private subnets and allow access only from the application security group.
  • Encrypt at creation and enforce TLS. You cannot add encryption to a running instance.
  • Use Secrets Manager or IAM authentication. Do not store master passwords in code or environment files.
  • Keep retention at 7 days or more, and practise a point-in-time restore so the process is known before it is needed.
  • Use RDS Proxy for connection-heavy workloads such as Lambda or large fleets, since it pools connections and reduces failover disruption.
  • Test failover. Reboot with failover on a staging instance and measure how your application reconnects.
Mistake Problem Fix
Treating a replica as high availability Async lag, manual promotion Enable Multi-AZ, then add replicas for reads
No Storage Auto Scaling Disk full means write failures Set --max-allocated-storage
Public access enabled Internet-reachable database Private subnets and security groups
Backup retention of 0 No point-in-time restore Retention of 7 to 35 days
Assuming Global failover is instant Longer outage than planned Rehearse, and plan for minutes
Encrypting too late Cannot encrypt in place Snapshot, encrypted copy, restore

Quick Reference & Troubleshooting Commands

Task Command
List instances aws rds describe-db-instances
Wait until available aws rds wait db-instance-available --db-instance-identifier ID
Create a read replica aws rds create-db-instance-read-replica
Promote a replica aws rds promote-read-replica --db-instance-identifier ID
Manual snapshot aws rds create-db-snapshot
Restore to a point in time aws rds restore-db-instance-to-point-in-time
Test failover aws rds reboot-db-instance --db-instance-identifier ID --force-failover
Clone an Aurora cluster aws rds restore-db-cluster-to-point-in-time --restore-type copy-on-write
Generate an IAM token aws rds generate-db-auth-token
View recent events aws rds describe-events --source-type db-instance --duration 120
Symptom First check What to look for
Cannot connect from the app Security group and subnet group Source is the app security group, same VPC
Writes failing suddenly FreeStorageSpace metric Disk full, Auto Scaling not enabled or at its maximum
Slow reads on a replica ReplicaLag metric Heavy writes on the primary, undersized replica
Connections refused under load DatabaseConnections metric Connection limit reached, consider RDS Proxy
Unexpected restart describe-events Failover, maintenance or storage events

Resources

AWS Direct Connect vs VPN: Run Both as Failover

AWS Direct Connect vs VPN: Run Both as Failover

Run AWS Direct Connect as primary and Site-to-Site VPN as BGP failover. Size the backup, set route preference and test it before an outage does.

10 min read•Aug 2026
Lambda vs Fargate vs EC2 Spot: The Cost Crossover

Lambda vs Fargate vs EC2 Spot: The Cost Crossover

Lambda vs Fargate vs EC2 Spot, at the crossover where Lambda stops being cheaper — 2026 pricing, invocation thresholds, and interruption math.

5 min read•Aug 2026
Secrets Manager vs Parameter Store vs Vault

Secrets Manager vs Parameter Store vs Vault

Secrets Manager vs Parameter Store vs Vault: cost math, rotation, dynamic secrets and a decision flow, plus the Vault, IBM and OpenBao licensing context.

10 min read•Aug 2026
AWS VPC Security: Hardening Every Layer

AWS VPC Security: Hardening Every Layer

Harden your AWS VPC in layers: subnets, Security Groups, NACLs, Flow Logs, endpoints, and IAM conditions, with CLI examples for production.

10 min read•Jul 2026
Event-Driven Architecture on AWS Explained

Event-Driven Architecture on AWS Explained

Build event-driven systems on AWS with SQS, SNS, EventBridge and Kinesis: fan-out, DLQs, idempotent consumers and queue-based scaling.

11 min read•Jul 2026
S3 vs RDS vs DynamoDB: Choosing AWS Storage

S3 vs RDS vs DynamoDB: Choosing AWS Storage

Choosing S3, RDS, or DynamoDB wrong costs you in performance, cost, and scalability. Here is a practical decision guide based on your actual access patterns.

5 min read•Jul 2026
AWS Cost Optimisation: 8 Actions That Cut Bills

AWS Cost Optimisation: 8 Actions That Cut Bills

Cut your AWS bill without re-architecting: eight ordered steps from anomaly alerts and tagging to rightsizing, VPC endpoints, Savings Plans and Spot.

11 min read•Jul 2026
EC2 vs Lambda vs Fargate: Choosing AWS Compute

EC2 vs Lambda vs Fargate: Choosing AWS Compute

Choose between EC2, Lambda and Fargate using traffic shape, state and runtime limits, with worked cost break-evens instead of rules of thumb.

11 min read•Jul 2026

Explore More in AWS Storage and Databases

All 6 Topics

Frequently Asked Questions

Is Configuring Amazon RDS and Aurora for Production free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Configuring Amazon RDS and Aurora for Production topic cover?

Configure RDS Multi-AZ, read replicas, encryption, backups and Aurora Serverless v2, Global Database and cloning for production databases on AWS.

Found a mistake, an outdated step or a broken link?