Interview Prep/AWS/RDS, Aurora and DynamoDB

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 →

  1. Size the replica the same as the primary, with the same storage performance
  2. For MySQL, turn on parallel apply (replica_parallel_workers)
  3. 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.

aws All AWS questions Roadmap: AWS core services

More on RDS, Aurora and DynamoDB