In this post I will continue with AWS Route 53 health checks. Health checks can be used for active-active and active -passive load balancing for our services. For example, we may have three web server instances with same configuration and these instances can be running in different regions. We can use health checks on thse instances and so DNS queries for our web site will respond as only healthy instances. By doing this we have an active-active failover system. We can create HTTP,HTTPS and TCP health checks on AWS route 53. So we can check of our instances for any protocol like web,mysql,ftp or custom tcp port. Today I will create a HTTP health check and also configure a SNS topic to be alerted if our health checks fail.
So Let’s start. I will use a demo topology like below. In this demo I will show both health check and failover policy.
First of all I will create an health check for my secondary site which is an EC2 instance.
I want to explain the meaning of the values here:
Protocol : Which protocol we will check , HTTP, HTTPS or TCP?
IP Address/Domain Name : The IPV4 address/Domain Name of the endpoint on which we want to perform health checks.
Port : The port on the endpoint on which we want to perform the health checks.
Hostname : The value we pass in the Host header in HTTP and HTTPS health checks. If we don’t specify this it will use the IP Address. For TCP protocol ,host header is not sent.
Path: The path to perform health checks like index.html , healthcontrol.php etc
Request Interval : The number of seconds between the each health check request. If you choose Fast , get ready for additional cost
Failure Threshold : The number of consecutive health checks.
Enable String Matching: If you want to search for a string in response body you can enable it.
URL: The URL for health checks will be performed on.
Health Check Type: Basic or Basic+additional options you enabled.
I will create records for ELB and EC2 by using failover policy.
Now we can test Route53 responses for our queries. As you see DNS query for my primary website is as expected, MYELB:
Now I will stop the apache services on my instances web1 and web2 and Route53 will forward my requests to my secondary website, EC2 22.214.171.124:
It is time to test the health check now. Before testing it I will create an alarm and create a notification for it. Then I will stop the apache service on my secondary website EC2, and wait for SNS email.
I’ve created it and it seem ok as our apache server is running:
I will stop it now and wait for the SNS email:
Again if I start apache on my EC2, alarm will be ok and SNS will send an email again ( if you configured Cloudwatch alarm for sending notification for the status “ok”)
As you see configuration of health checks are so easy. You can create mixed failover scenarios by using latency record set and weighted records.
If you have any question or comment please feel free to write and don’t forget to share please.