DEV Community

Wakeup Flower
Wakeup Flower

Posted on

DNS failover in Route 53

Where to configure DNS failover

In AWS, DNS failover is configured in Amazon Route 53 — AWS’s DNS service.


How DNS failover works in AWS

  1. Route 53 health checks
  • You create a health check for your primary site (the primary region’s load balancer).
  • Route 53 constantly monitors whether your primary site is healthy (by pinging an endpoint or checking HTTP status).
  1. DNS records with failover routing policy
  • You create two DNS records for your domain:

    • Primary record pointing to your primary region’s load balancer.
    • Secondary (failover) record pointing to your DR region’s load balancer.
  • You assign a failover routing policy to the DNS records so Route 53 knows which one is primary and which one is secondary.

  1. Automatic failover
  • If Route 53 detects your primary site is unhealthy via the health check, it automatically routes traffic to the secondary record (the DR region’s load balancer).

Step-by-step example

Let’s say your domain is example.com.

Step 1 — Set up Route 53 hosted zone

  • In AWS console, go to Route 53 → Hosted Zones.
  • Select your domain.

Step 2 — Create health check

  • Go to Route 53 → Health Checks.
  • Create a health check that monitors your primary region’s load balancer endpoint (using HTTP, HTTPS, or TCP check).
  • Set the check interval (default is every 30 seconds).

Step 3 — Create DNS records with failover

  • In your hosted zone, create two A or Alias records:
  1. Primary record:
 * Type: A (Alias)
 * Alias target: Primary region’s load balancer.
 * Routing policy: Failover
 * Failover record type: Primary
 * Associate with health check you created.
Enter fullscreen mode Exit fullscreen mode
  1. Secondary record:
 * Type: A (Alias)
 * Alias target: DR region’s load balancer.
 * Routing policy: Failover
 * Failover record type: Secondary.
Enter fullscreen mode Exit fullscreen mode

How it works in practice

  • Under normal conditions → Route 53 resolves your domain to the primary region’s load balancer IP.
  • If Route 53 health check fails → DNS automatically switches to the DR region’s load balancer.

Extra tip

DNS failover is not instantaneous — DNS changes depend on TTL (time-to-live) settings. You can reduce TTL (e.g., to 30 seconds) so Route 53 switches faster.

                         +--------------------+
                         |  Route 53 Hosted  |
                         |      Zone         |
                         +--------------------+
                                  |
                                  | DNS query for example.com
                                  |
             +-------------------------------------------+
             |                                           |
+----------------------------+              +----------------------------+
| Primary Region Load       |              | Disaster Recovery Region   |
| Balancer (ELB)            |              | Load Balancer (ELB)       |
+----------------------------+              +----------------------------+
             |                                           |
   +--------------------+                        +--------------------+
   | Auto Scaling Group|                        | Auto Scaling Group|
   | EC2 Instances     |                        | EC2 Instances     |
   +--------------------+                        +--------------------+
             |                                           |
   +--------------------+                        +--------------------+
   | DynamoDB Table    |<---------------------> | DynamoDB Global    |
   | (Primary Region)  |                        | Table (DR Region) |
   +--------------------+                        +--------------------+

Route 53 Health Check:
   - Monitors Primary Region Load Balancer
   - If unhealthy → Route 53 fails over to DR Region Load Balancer

Enter fullscreen mode Exit fullscreen mode

Top comments (0)