6. Configure Route 53 DNS Failover for web traffic

Amazon Route 53 service monitors the health and performance of MiaRec instances. Using DNS failover, it can route the web traffic from an unhealthy instance to a healthy one.

Prerequisites:

  • Your domain name has to be managed by Amazon Route 53, otherwise it will not be possible to use DNS Failover. You can register new domain name for your MiaRec HA cluster or use existing one.

Create Hosted Zone

  1. Sign in to the AWS Management Console and open the Amazon Route 53 console at https://console.aws.amazon.com/route53/.
  2. In the navigation pane of the Route 53 console, choose Hosted zones, and then choose Create Hosted Zone.
  3. Enter the registered domain name into Domain Name. In this guide, we use domain miarecorder.com as an example.

MiaRec on AWS

Create A-records for MiaRec servers (miarec1 and miarec2)

We need to create DNS A-record for each of our MiaRec servers. In this example, we use "miarec1" and "miarec2", but you can name it whatever you want.

Name Type Alias TTL Value Routing Policy
miarec1 A No 300 x.x.x.x Simple
miarec2 A No 300 y.y.y.y Simple

Where:

  • x.x.x.x is the Elastic IP address (public) of the first MiaRec instance
  • y.y.y.y is the Elastic IP address (public) of the second MiaRec instance

To create A-records:

  1. In the navigation pane of the Route 53 console, choose Hosted zones, select the domain name, and then choose Create Record Set.
  2. Choose A - IPv4 address for Type.
  3. Enter Elastic IP address of the MiaRec EC2 instance into Value field.
  4. Choose Simple for Routing Policy
  5. A default TTL value is ok
  6. Repeat these steps for the second MiaRec EC2 instance.

MiaRec on AWS

Create Health checks for MiaRec web servers

For DNS Failover, we need to configure health checks for each of servers.

For each MiaRec instance:

  1. In the navigation pane of the Route 53 console, choose Hosted checks, select the domain name, and then choose Create health check.
  2. Choose a convenient name, like "miarec-www-primary" and "miarec-www-secondary".
  3. Choose Domain name from Specify endpoint by options.
  4. Choose HTTP for Protocol (this option should be HTTPS if HTTP is disabled)
  5. Enter the DNS name of the MiaRec EC2 instance, in our example, domain names are "miarec1.miarecorder.com" and "miarec2.miarecorder.com".
  6. Choose 80 for Port
  7. Enter "login" for Path (this health check will verify if login page is accessible).
  8. Keep other settings as default.
  9. Repeat these steps for the second MiaRec EC2 instance.

MiaRec on AWS

In a couple of minutes, you should be able to see health check report as shown in the following screenshot.

MiaRec on AWS

Create DNS A-record for web traffic (with failover)

Now, we are going to create DNS A-record, which will be used by end users for accessing MiaRec web portal, something like "recordings.mycompany.com". We will configure DNS Failover for this record. Amazon Route 53 services will route web traffic to the secondary server, when health check for the primary server returns error.

Create two records with the following settings:

Name Type Alias TTL Value Routing Policy Failover Record Type Set ID Health Check to Associate
recordings A No 60 x.x.x.x Failover Primary recordings-Primary miarec-www-primary
recordings A No 60 y.y.y.y Failover Secondary recordings-Secondary miarec-www-secondary

Where:

  • x.x.x.x is the Elastic IP address (public) of the first MiaRec instance
  • y.y.y.y is the Elastic IP address (public) of the second MiaRec instance

To create A-records with DNS Failover, repeat for each MiaRec instance:

  1. In the navigation pane of the Route 53 console, choose Hosted zones, select the domain name, and then choose Create Record Set.
  2. Choose A - IPv4 address for Type.
  3. Select 60 for TTL. Recommended value is between 30 to 60 seconds. Each client caches DNS records. In case of failover, the web browser may attempt to access the unhealthy instance until cache expires.
  4. Enter Elastic IP address of the MiaRec EC2 instance into Value field.
  5. Choose Failover for Routing Policy
  6. Choose Primary for the first instance and Secondary for the second instance for Failover Record Type
  7. Choose a convenient name for Set ID
  8. Associate this record to the corresponding health check, created previously.
  9. Repeat these steps for the second MiaRec EC2 instance.

Below screenshots, demonstrate configuration of Record Set for both MiaRec instances.

MiaRec on AWS

MiaRec on AWS

Test DNS failover

Navigate in web browser to http://recordings.yourdomain.com.

Login as administrator and navigate to Administration -> Maintenance -> Recording Servers. You should see the private IP address of this instance. This information allows you to determine on which instance you are now. The primary instance should be in a subnet 10.0.1.x and the secondary in 10.0.2.x.

MiaRec on AWS

Now, simulate failure using one of the following methods:

  • Stop Apache web server using SSH (on Ubuntu the command is sudo service apache2 stop, on Centos it is sudo service httpd stop).
  • Shutdown the server via SSH using command sudo shutdown -h now
  • Stop instance via Actions menu in Amazon EC2 Dashboard.

Try to access MiaRec web portal using web browser. It may take a few minutes for Amazon Route 53 to detect server failure (by default, it checks the server health every 30 seconds and requires at least 3 consecutive failures before the server is marked unhealthy). Once the server is marked unhealthy, the domain name http://recordings.yourdomain.com is automatically routed to the secondary MiaRec instance IP-address. If the TTL value is reasonably small (no more than 60 seconds), then failover should shortly after that.

Within 3-4 minutes, you should be able to access the MiaRec web portal again. Login as administrator and navigate Administration -> Maintenance -> Recording Servers to check on which instance you are now.

MiaRec on AWS

Now, restore the primary server and verify if web-traffic is routed back to it after 3-5 minutes.