A read replica's `ReplicaLag` keeps growing and reports show stale data.
IntermediateTroubleshootingRDS, Aurora and DynamoDB
Answer
Likely causes → The replica is smaller than the primary, or IOPS-bound. Heavy write bursts or long-running queries on the replica cause conflicts (PostgreSQL max_standby_streaming_delay). MySQL replication may apply single-threaded.
Diagnose →
aws cloudwatch get-metric-statistics --namespace AWS/RDS --metric-name ReplicaLag \
--dimensions Name=DBInstanceIdentifier,Value=mydb-replica --statistics Maximum --period 60 \
--start-time $(date -u -d '-3 hour' +%FT%TZ) --end-time $(date -u +%FT%TZ)
aws rds describe-db-instances --db-instance-identifier mydb-replica --query 'DBInstances[].[DBInstanceClass,StorageType,Iops]'
Fix →
- Size the replica the same as the primary, with the same storage performance
- For MySQL, turn on parallel apply (
replica_parallel_workers) - Move heavy analytics to a dedicated replica or to Aurora, where replicas share storage and lag is usually well under a second
Prevent → Alarm on lag, and route reads that must not be stale to the primary.
More on RDS, Aurora and DynamoDB
The app cannot connect to RDS: `psql: error: connection to server at "mydb.abc.us-east-1.rds.amazonaws.com" (10.0.3.12), port 5432 failed: Connection timed out`.Beginner`FATAL: password authentication failed for user "postgres"` and nobody knows the master password.Beginner`FATAL: no pg_hba.conf entry for host "10.0.1.25", user "app", database "orders", no encryption`.IntermediateApp logs show `FATAL: remaining connection slots are reserved for non-replication superuser connections` (or MySQL `ERROR 1040 (HY000): Too many connections`).IntermediateRDS status shows `storage-full` and writes fail.IntermediateAfter a Multi-AZ failover, some app servers keep failing with connection errors for 10+ minutes while others recover in a minute.Advanced