Amazon Route 53 Failover Routing
Amazon Route 53 Failover Routing
177
PrimaryWebSiteURL 35.80.229.177/cafe
SecondaryWebsiteURL 35.95.196.197/cafe
CafeInstance2IPAddress 35.95.196.197
The activity environment starts with two Amazon Elastic Compute Cloud (Amazon EC2)
instances that have already been created. Each of the instances has the full LAMP
stack installed and the café website deployed and running. The EC2 instances are
deployed in different Availability Zones. For example, if the web servers are
running in the us-west-2 Region, then one of the web servers runs in the us-west-2a
Availability Zone and the other one runs in the us-west-2b Availability Zone.
You will configure your domain such that, if the website in the primary
Availability Zone becomes unavailable, Amazon Route 53 will automatically fail over
application traffic to the instance in the secondary Availability Zone.
When you are finished, your environment will look like the following architecture:
The architecture diagram shows the final state of the infrastructure that you
build. Route 53 records store the IP address of the EC2 instance in each
Availability Zone. User requests are normally sent to the IP address corresponding
to Café Instance1 in Availability Zone 1. If Café Instance1 is unavailable,
requests are routed to Café Instance2 in Availability Zone 2 based on the
configuration in the Route 53 records. When Café Instance1 becomes unavailable, a
Route 53 health check alarm is invoked, and an email alert is sent to the email
address provided.
Objectives
After completing this activity, you should be able to do the following:
Configure a Route 53 health check that sends emails when the health of an HTTP
endpoint becomes unhealthy.
Duration
This activity requires approximately 45 minutes to complete.
Next to Start Lab, choose AWS to open the AWS Management Console on a new browser
tab. The system automatically signs you in.
Tip If a new browser tab does not open, a banner or icon at the top of your browser
will indicate that your browser is preventing the site from opening pop-up windows.
Choose the banner or icon, and choose Allow pop-ups.
Arrange the AWS Management Console so that it appears alongside these instructions.
Ideally, you should be able to see both browser tabs at the same time to follow the
lab steps.
Important: Do not change the lab Region unless specifically instructed to do so.
At the top of this page, choose Details. For AWS, choose Show. A Credentials panel
opens.
Copy the values for the following parameters, and paste them into a text editor to
use later.
CafeInstance1IPAddress
PrimaryWebSiteURL
SecondaryWebsiteURL
CafeInstance2IPAddress
Navigate to the browser tab with the AWS Management Console. In the Search bar,
enter and choose EC2 to open the EC2 Management Console.
Two EC2 instances have already been created for you. CafeInstance1 is running in
Cafe Public Subnet 1 (us-west-2a), and CafeInstance2 is running in Cafe Public
Subnet 2 (us-west-2b).
The URLs that you copied earlier correspond to the café application running on each
instance.
Although both EC2 instances have the same configuration and application installed,
one instance is a primary instance.
Open a new browser tab, and paste the value for PrimaryWebSiteURL.
Along with other information about the café, notice the Server Information that is
displayed. It shows information about the EC2 instance and the Availability Zone
where it is running.
Open another browser tab, and paste the value for SecondaryWebsiteURL. Confirm that
the second EC2 instance has similar configurations as the first instance.
The Order Confirmation page reflects the time that the order was placed in the time
zone where the web server is running.
You have now confirmed that two instances are running the café application. Each
application is running in a different Availability Zone to provide high
availability.
In the AWS Management Console, from the Services menu, enter and choose Route 53 to
open the Route 53 Management Console.
You can safely ignore any error messages displayed because of AWS Identity and
Access Management (IAM) restrictions placed on lab accounts.
Choose Create health check, and configure the following options. Leave the default
values for all other fields.
IP address: Paste in the Public IPv4 address of CafeInstance1. You can find this
value in the EC2 console, or you can copy the IP address from the
CafeInstance1IPAddress value that you copied earlier.
Expand Advanced configuration, and configure the following options. Leave the
default values for all other fields.
Choose Next.
For Get notified when health check fails, configure the following options:
Recipient email address: Enter an email address that you can access.
Route 53 now checks the health of your site by periodically requesting the domain
name that you provided and verifying that it returns a successful response.
The health check might take up to a minute to show a Healthy Status. Choose the
refresh icon to update your view of the current status.
This tab provides a view of the status of the health check over time. It might take
a few seconds before the chart becomes available. Choose the refresh icon to update
your view.
Check your email. You should have received an email from AWS Notifications.
In the email, choose the Confirm subscription link to finish setting up the email
alerting that you configured when you created the health check.
In the Route 53 console, in the left navigation pane, choose Hosted zones.
These two records were created when the domain was registered with Route 53. The
NS, or name server record, lists the four name servers that are the authoritative
name servers for your hosted zone in the Value/Route traffic to column. You should
not add, change, or delete name servers from this record.
The SOA, or start of authority record, identifies the base Domain Name System (DNS)
information about the domain in the Value/Route traffic to column. It was also
created when the domain was registered with Route 53.
The A-type record that you created should now appear as the third record on the
Hosted zones page.
Record type: Choose A - Routes traffic to an IPv4 address and some AWS resources.
Value: In the text box, enter the IP address for CafeInstance2IPAddress. To find
this value, at the top of these instructions, choose Details, and then choose Show,
or copy it from the values that you pasted into a text editor earlier in the lab.
Another A-type record should now be listed on the Hosted zones page.
You have now configured your web application to fail over to another Availability
Zone.
Select the check box for either one of the A records. A Record details panel
appears that includes the Record name. Copy the Record name value of the A record.
Open a new browser tab. Paste the A record name, enter /cafe at the end of the URL,
and then load the page.
The café primary website should load, as indicated by the Server Information
section of the page, which should display the Region/Availability Zone.
Return to the AWS Management Console. On the Services menu, enter and choose EC2
and then choose Instances.
Select CafeInstance1.
The primary website now stops functioning. The Route 53 health check that you
configured notices that the application is not responding, and the record entries
that you configured cause DNS traffic to fail over to the secondary EC2 instance.
Select Primary-Website-Health, and in the lower pane, choose the Monitoring tab.
You should see failed health checks within minutes of stopping the EC2 instance.
If you do not get the correct results, reconfirm that the Status of Primary-
Website-Health is Unhealthy, and then try again. It might take a few minutes for
the DNS changes to propagate.
Check your email. You should have received an email from AWS Notifications titled
"ALARM: Primary-Website-Health-awsroute53-..." with details about what initiated
the alarm.
You have now successfully confirmed that your application environment can fail over
from its primary Availability Zone to its secondary Availability Zone if the server
in the primary Availability Zone fails.
Conclusion
Congratulations! You now have successfully done the following:
Configured a Route 53 health check that sends emails when the health of an HTTP
endpoint becomes unhealthy