Route 53 Flashcards
Route 53
is a managed Domain Name System
DNS
collection of rules and records which helps clients understand how to reach a server through its domain name
the most common DNS records in AWS
- A: hostname to IPv4
- AAAA: hostname to IPv6
- CNAME: hostname to hostname
- Alias: hostname to AWS resource
how does Route 53 work
We have a web browser and it wants to access out application, which is on an application server with IPv4
32.45.67.85.
Web browser is going to make a DNS request to our DNS system which is Route 53 in this instance. In the request the browser will tell Route 53: tell me where this hostname is located - myapp.mydomain.com.
Route 53 will say: Here is the IP you should be looking at. It is 32.45.67.85. This is an A record because we have mapped a host name to a IP.
The web browser has finished the DNS request and knows the target IP, can do an HTTP request, and the server will then receive the request and say okay, here is your HTTP response.
Route 53 can use different kinds of domains.
- It can use public domain names that you own or buy.
2. private domain that can only be resolved by your instances within your VPC.
check IP for domain name
nslookup on Windows
dig on Linux
TTL
a way for web browsers and clients to cache the response of a DNS query, in order not to overload the DNS.
how TTL works
we’re going to make a DNS request to Route 53 for myapp.mydomain.com.
Route 53 will send back the IP: 32.45.67.85, which is a A record, because it’s domain to IP. And then, on top of it,
it’s going to also send back the TTL, for ex., 300 seconds
Web browser will cache that DNS request and the response for the TTL duration. And any time we request myapp.mydomain.com, the web browser will just look internally. If we have something changing on the Route 53 side, for example, the IP back is now 195.23.45.22,
then our cache will be updated, but only after the TTL has expired.
When you make a change on the Route 53 DNS Record
that doesn’t mean necessarily that all the clients will see that change right away. They have to wait for the TTL to expire before they can see that change.
high vs low TTL
high TTL is considered to be something like 24 hours. You get way less traffic on your DNS, so Route 53 will have less queries because records are cached for 24 hours. But there’s a possible chance of out-dated records, especially if you change them on Route 53.
Low TTL, for example, 60 seconds, will incur a lot more traffic on your DNS, but also, the records will be out-dated for less time. And it will be very easy to change the records.
TTL is something you have to make a decision on, based on what your application is and does.
each DNS record must specify
TTL
use case for a CNAME record and an Alias record
if you have an AWS Resource that could be a Load Balancer or CloudFront, it will expose a AWS hostname.
For example, if I have a Load Balancer, it could be lb1-1234.us-east-two.elb.amazonaws.com. So, this is your URL that Amazon Web Services controls, but you don’t.
What you want to do is to expose your application as myapp.mydomain.com, but you want it to point to your Load Balancer. This is why we need Alias or CNAME
CNAME
points a hostname to any other hostname, only work for non root domain, so it has to be something.mydomain.com. It cannot just be mydomain.com.
Alias
very similar to CNAME, but they point a hostname to an AWS Resource. It has to be app.mydomain.com to blabla.amazonaws.com.
It has to point to an AWS Resource, specifically, whereas CNAME could point to anything. The great thing about Aliases is that they work for both root domain and non root domain.
On top of it, Alias records are free of charge and have capability for native health checks.
Alias OR CNAME choice
if you have a root domain then you have to use an Alias. If it’s a non root domain, you can use either,
and usually it’s always going to be an Alias anyway,
because you point to an AWS Resource which will be free to charge and better.
Simple routing policy
We have a web browser and Route 53. We want to know where’s foo.example.com is. Route 53 will reply, it is an A record and the IP is 11.22.33.44.
So we just use it, when we need to redirect to a single resource with simple routing,
You can return multiple values to a client, in which case the client sees all the values and the clients will choose a value at random to use.
Simple routing policy restriction
you cannot attach health checks.
Weighted routing policy
controls the percentage of the requests that will go to specific endpoints.
We have Route 53, and we’re going to assign different IP addresses, and we’re going to assign weight, for ex., 70, 20, and 10. The sum does not have to be 100
Now our clients will send 70% of the traffic to the first instance, 20% of the traffic to the second instance and 10% of the traffic to the last instance.
Weighted routing policy Use case
To deploy a new application version and you wanted to test only 1% of the traffic on this new app version
where it’s helpful to split traffic between two regions
You can also associate this with health checks, so if one EC2 instance is not working properly, no traffic will be sent to it.
Latency routing policy
Latency will redirect the user to the server that has the least latency close to us. Helpful when latency for the users is your priority.
Latency is going to be evaluated in terms of the user’s proximity to the AWS region.
Latency routing policy example
Say we have two EC2 instances, one on the west of the United States and one in Sydney in Australia.
And we have all these users around the world. Based on the Latency Routing Policy, the four users on the left-hand side of the map will be redirected to the US,
while my users on the right-hand side of the map will be redirected to Australia.
health checks
if an instance is unhealthy, just like an ELB, Route 53 will not send traffic to that instance. An instance is an IP or URL, is deemed unhealthy if it fails three health checks in a row, and it’s deemed healthy if it passes
three health checks in a row.
default health check interval
30 second
fast health check
10 seconds, but those will lead to higher cost.