How can I configure failover routing in route 53?

240    Asked by DavidPiper in AWS , Asked on Jun 3, 2024

 I am currently engaged in a particular task in which I need to ensure high availability for my particular web-based services by the method of configuring failover routing in route 53. If my primary EC2 instance becomes unhealthy, the traffic should be redirected to a secondary instance. Explain to me the steps how I can take to set this up. 

Answered by David WHITE

 In the context of AWS, here are the steps given of how you can configure the failover routing in route 53 to ensure high availability for your web-based services:-

Creating health checks

Try to navigate to the route 53 console where you should create two health checks: one for the primary EC2 Instance and the other for the secondary EC2 Instance.

You should specify the endpoint and also the protocol for each health check.

You can set the criteria for determining the Instance health check.

Creating hosted zone

You should try to ensure that you have a hosted zone for your domains. If there is not, then you should approach to create one in the Route 53 console.

Creating the DNS records

You should go to the hosted zone where you should create a new record which will be called as primary record. You are also recommended to create another record for the same domain and subdomain which will be called a secondary record.

Configure failover routing

You should try to ensure that the primary and secondary records are correctly Configured with their respective health checks.

Now route 53 will monitor the health of both instances. If the primary Instance fails to health check, route 53 will automatically route traffic to the secondary Instance.

Here is the example given by using the AWS command line interface (CLI):-

  # Create health checks

Aws route53 create-health-check –caller-reference unique-string1 –health-check-config IPAddress=PRIMARY_IP,Port=80,Type=HTTP

Aws route53 create-health-check –caller-reference unique-string2 –health-check-config IPAddress=SECONDARY_IP,Port=80,Type=HTTP

# Note the Health Check IDs from the response for further use
# Create the primary DNS record
Aws route53 change-resource-record-sets –hosted-zone-id HOSTED_ZONE_ID –change-batch ‘{
    “Changes”: [
        {
            “Action”: “CREATE”,
            “ResourceRecordSet”: {
                “Name”: “example.com”,
                “Type”: “A”,
                “SetIdentifier”: “Primary”,
                “Failover”: “PRIMARY”,
                “HealthCheckId”: “HEALTH_CHECK_ID_PRIMARY”,
                “TTL”: 60,
                “ResourceRecords”: [
                    {
                        “Value”: “PRIMARY_IP”
                    }
                ]
            }
        }
    ]
}’
# Create the secondary DNS record
Aws route53 change-resource-record-sets –hosted-zone-id HOSTED_ZONE_ID –change-batch ‘{
    “Changes”: [
        {
            “Action”: “CREATE”,
            “ResourceRecordSet”: {
                “Name”: “example.com”,
                “Type”: “A”,
                “SetIdentifier”: “Secondary”,
                “Failover”: “SECONDARY”,
                “HealthCheckId”: “HEALTH_CHECK_ID_SECONDARY”,
                “TTL”: 60,
                “ResourceRecords”: [
                    {
                        “Value”: “SECONDARY_IP”
                    }
                ]
            }
        }
    ]
}’

This particular health check would ensure that the traffic is routed to the secondary Instance if the primary Instance becomes unhealthy.



Your Answer

Interviews

Parent Categories