Interview Prep/AWS/RDS, Aurora and DynamoDB

After a Multi-AZ failover, some app servers keep failing with connection errors for 10+ minutes while others recover in a minute.

AdvancedTroubleshootingRDS, Aurora and DynamoDB
Answer

Likely causes → A failover flips the endpoint's DNS CNAME to the standby. Clients that cache DNS for a long time (JVM networkaddress.cache.ttl set to forever, or a misconfigured local resolver) or keep stale pooled connections keep hitting the old IP.

Diagnose →

aws rds describe-events --source-identifier mydb --source-type db-instance --duration 120
dig +short mydb.abc.us-east-1.rds.amazonaws.com
# on the bad host
getent hosts mydb.abc.us-east-1.rds.amazonaws.com

Fix →

  1. Set the JVM DNS TTL to a low value (networkaddress.cache.ttl=5)
  2. Turn on pool connection validation and max lifetime (for example, HikariCP maxLifetime)
  3. Restart the affected app instances to recover now

Prevent → Use RDS Proxy (it keeps client connections during failover) or the AWS Advanced JDBC Wrapper, and test failover regularly with aws rds reboot-db-instance --force-failover.

aws All AWS questions Roadmap: AWS core services

More on RDS, Aurora and DynamoDB