How to Use Health Check in Route 53 for Reliable DNS Routing
In AWS Route 53, you use
health checks to monitor the health of your endpoints like web servers or IP addresses. You create a health check and then associate it with DNS records so Route 53 routes traffic only to healthy endpoints.Syntax
A Route 53 health check requires these main parts:
- IPAddress or Domain Name: The endpoint to check.
- Port: The port number to connect to (e.g., 80 for HTTP).
- Type: The protocol used (HTTP, HTTPS, TCP).
- Request Interval: How often Route 53 checks the endpoint.
- Failure Threshold: Number of failed checks before marking unhealthy.
bash
aws route53 create-health-check --caller-reference unique-string --health-check-config IpAddress=192.0.2.44,Port=80,Type=HTTP,ResourcePath="/",RequestInterval=30,FailureThreshold=3
Example
This example creates a health check for a web server at IP 192.0.2.44 on port 80 using HTTP. It checks every 30 seconds and marks unhealthy after 3 failures.
bash
aws route53 create-health-check --caller-reference "example-health-check-001" --health-check-config IpAddress=192.0.2.44,Port=80,Type=HTTP,ResourcePath="/",RequestInterval=30,FailureThreshold=3
Output
{
"HealthCheck": {
"Id": "abcdef12-3456-7890-abcd-ef1234567890",
"CallerReference": "example-health-check-001",
"HealthCheckConfig": {
"IPAddress": "192.0.2.44",
"Port": 80,
"Type": "HTTP",
"ResourcePath": "/",
"RequestInterval": 30,
"FailureThreshold": 3
},
"HealthCheckVersion": 1
}
}
Common Pitfalls
- Not associating the health check with a DNS record, so Route 53 does not use it for routing.
- Using incorrect IP address or domain name in the health check.
- Setting too short a
RequestIntervalcausing unnecessary load. - Not allowing Route 53 health check IP ranges in your firewall, causing false failures.
bash
aws route53 change-resource-record-sets --hosted-zone-id Z1234567890 --change-batch '{"Changes":[{"Action":"UPSERT","ResourceRecordSet":{"Name":"example.com","Type":"A","SetIdentifier":"primary","HealthCheckId":"abcdef12-3456-7890-abcd-ef1234567890","TTL":60,"ResourceRecords":[{"Value":"192.0.2.44"}]}}]}'Output
{
"ChangeInfo": {
"Id": "/change/XYZ1234567890",
"Status": "PENDING",
"SubmittedAt": "2024-06-01T12:00:00Z"
}
}
Quick Reference
| Parameter | Description | Example |
|---|---|---|
| IpAddress | The IP address to check | 192.0.2.44 |
| Port | Port number for the check | 80 |
| Type | Protocol type (HTTP, HTTPS, TCP) | HTTP |
| ResourcePath | Path to request for HTTP/HTTPS | / |
| RequestInterval | Seconds between checks | 30 |
| FailureThreshold | Failures before unhealthy | 3 |
| HealthCheckId | ID to link with DNS record | abcdef12-3456-7890-abcd-ef1234567890 |
Key Takeaways
Create a health check with the correct IP, port, and protocol to monitor your endpoint.
Associate the health check ID with your DNS record to enable health-based routing.
Allow Route 53 health check IP ranges in your firewall to avoid false failures.
Set reasonable check intervals and failure thresholds to balance responsiveness and load.
Use health checks to improve availability by routing traffic only to healthy endpoints.