After an RDS Multi-AZ failover, the database is healthy within 2 minutes but the Java app keeps failing for 20 minutes. Why, and how do you fix it?

IntermediateScenarioData and databases
Answer

Situation read → The failover changes which IP the RDS endpoint points to. The app is still talking to the old IP, either because of DNS caching or because of stale pooled connections.

What I'd do →

  1. Check JVM DNS caching: with a security manager or certain settings it caches forever. Set a short TTL:
# $JAVA_HOME/conf/security/java.security
networkaddress.cache.ttl=5
  1. Configure the connection pool to validate and recycle: HikariCP maxLifetime under a few minutes, keepaliveTime, and a connection timeout so broken connections fail fast.
  2. Use a driver that understands failover (the AWS Advanced JDBC Wrapper) or put RDS Proxy in front, which keeps app connections and handles the switch.
  3. Test it: trigger failover in staging and measure app recovery.
aws rds reboot-db-instance --db-instance-identifier staging-db --force-failover

Why → Database failover is only as fast as the client's ability to notice and reconnect.

Interview tip → Say "test failover with --force-failover"; most teams only find this during a real one.

All Real-World Interview questions Roadmap: Interview readiness

More on Data and databases