Route53 DNS routing policies made easy

Idan Katalan
5 min readSep 16, 2020

--

We probably don’t hear much about DNS servers in our day to day job, but actually almost every time you access the internet, DNS server acts as the first contact from your browser to the site you are trying to access.

DNS servers acts as a translator from a alphanumeric-dotted string to an IP address so for example when you go to google.com it is the job of the DNS server to translate that address to a set of IP addresses the network will access in order to return the content you requested.

Although this is their main purpose, one can apply routing policy to route traffic between servers (or cluster in most of the cases).

DNS servers and load balancing can be quite complicated processes to master but in their core they serve a simple role in our infrastructure.

Why use DNS routing (Isn’t load balancer good enough ?)
DNS routing can sound a lot like a load balancer in the way that it routes the traffic between different servers but DNS is actually a layer on top of Load balancers.

While Load balancers are routing traffic between a specific cluster of servers located in the same region, DNS routing can route the traffic between different regions and serve users world-wide. The core difference is in the way DNS does its server lookup and how it affects the communication between the browser and the site servers.

DNS lookup

  1. The user types aws.amazon.com in the browser and the request gets to a DNS recursive resolver.
  2. The resolver searches for the root nameserver in order to reach the DNS server that serves this TLD (Top Level Domain). TLD is the last part of an address for example for: aws.amazon.com the TLD is .com. The TLD server stores all info about all sites in that TLD and their relevant IP.
  3. The resolver then makes another request directly to the TLD server in order to get the IP address of the domain’s nameserver.
  4. The domain’s nameserver return the IP of the domain requested.
  5. The response with the server’s domain IP address returned to the browser.
  6. From this point the browser calls the service directly using the server’s IP address, and the DNS server finishes its role.

Load Balancer Lookup (very simplified)

  1. The browser sends a request to a load balancer (directly to its IP).
  2. The load balancer gets the request and proxy it to the relevant server according to the policy configured on the load balancer.
  3. Each subsequent request to the site will go through the same route.

So, the main difference we can see between DNS resolver and Load balancer is that a load balancer is an intermediate part for all requests while a DNS resolver acts only on the first time you access the server to get its IPs.

DNS routing policies

DNS routing policies are ways to configure the DNS server to return different responses to users based on some policy configurations.
The simplest policy is a round-robin based DNS routing, other policies like geolocation (based on your physical distance) are explained below.

AWS route 53 offer these types of routing policies each fit to different situation

Simple routing

Simple routing is used to route requests to one destination and is mainly used for non prod related architectures. Once the Server/ELB/other Load balancer falls. The connection will not work as in this configuration there is no resiliency for errors.

Route 53 can route traffic for a single server or to a Load balancer.

Weighted

Weighted routing policies divide traffic between several destinations by weight (percentage).

Each endpoint will get a certain percent from the overall traffic received to the DNS server.

Geolocation based routing

Geolocation based routing routes requests based on the origin of the DNS request that arrived to the DNS server.

The DNS server gets the location of each request that arrives at the server and routes it to the closest (geographically) region supported by the server.

The Geolocation based granularity is by continents, countries, or U.S. states.

The Geolocation based routing is good for specific applications where traffic must be routed to a specific region.

Latency

Latency based routing policy, in contrast to geolocation based, is measuring the latency of request and returning the endpoint that will have the best latency (lowest).

Failover

Failover routing policy defines one active and one passive endpoints.

Once the health check to the active endpoint fails automatically routes the traffic to the passive endpoint making it active.

You can define only one active and one passive endpoints so if you have 2 failed endpoints the service becomes unavailable.

When the failed endpoint gets healthy again it goes back to the passive state.

Multi-answer routing policy

Multi-answer routing policy allows the DNS server to offer several endpoints randomly. For each endpoint there is a health check that makes sure that the endpoint is available. And if an endpoint is unhealthy it is removed from the list.

Let me know if you want to get more info about route 53 or on AWS services in general.

Have fun #BuildingTheFuture !

--

--