AWS Route 53: Latency-based Routing Policy

Maxat AkbanovMaxat Akbanov
4 min read

Latency-based routing (LBR) in AWS Route 53 is designed to route end-user requests to the AWS region that provides the lowest latency. This routing policy ensures that users are connected to the closest and fastest endpoint (in terms of network latency), enhancing performance by reducing delays in the communication path between the users and your application. Data about the latency between users and your resources is based entirely on traffic between users and AWS data centers.


How It Works

  • AWS measures network latency between different regions and end users.

  • When a DNS request is received, Route 53 determines which endpoint (from your configured set of endpoints) offers the lowest latency to the user’s location.

  • Route 53 returns the IP address (or CNAME) of the selected endpoint to the user's browser or application.

This helps ensure that users from different parts of the world are connected to the fastest AWS region, reducing response times and improving user experience.

Latency between hosts on the internet can change over time as a result of changes in network connectivity and routing. Latency-based routing is based on latency measurements taken over a period of time, and the measurements reflect these changes. For example a request that is routed to the Oregon Region this week might be routed to the Singapore Region next week.

Example Scenario

Assume your application is deployed in multiple regions:

  1. US-East (N. Virginia)

  2. EU-Central (Frankfurt)

  3. AP-Southeast (Singapore)

  • A user from Canada sends a request. Route 53 detects that the US-East region provides the lowest latency and directs the traffic there.

  • A user from Spain sends a request. Route 53 determines the EU-Central endpoint has the lowest latency and routes the traffic there.

  • Similarly, users in Hong Kong will be directed to the AP-Southeast region.


Use Case

Latency-based routing is particularly useful when:

  • You have a multi-region architecture, with your resources (like EC2 instances, load balancers, or API Gateway) deployed across multiple AWS regions.

  • You want to minimize latency and improve response times for users located around the globe.


Steps to Set Up Latency-Based Routing in Console

  1. Create your resources in multiple AWS regions (like an Application Load Balancer, EC2 instances, or an S3 static website).

  2. Set up a hosted zone in Route 53 for your domain.

  3. Create latency-based records in Route 53:

    • Choose A or CNAME record type.

    • Select the region associated with each endpoint.

  4. AWS will automatically direct traffic based on the latency between the user and your endpoints.


Latency-Based Routing Example Code in Terraform

resource "aws_route53_record" "latency_us_east_1" {
  zone_id = "Z03242191HGJ5WDONGNAD"  # Replace with your hosted zone ID
  name    = "latency-us-east-1"
  type    = "A"
  ttl     = 60

  set_identifier = "us-east-1"

  records = ["192.0.2.1"]  # Replace with your IP address or DNS name

  latency_routing_policy {
    region = "us-east-1"
  }
}

resource "aws_route53_record" "latency_us_west_2" {
  zone_id = "Z03242191HGJ5WDONGNAD"
  name    = "latency-us-west-2"
  type    = "A"
  ttl     = 60

  set_identifier = "us-west-2"

  records = ["192.0.2.2"]  # Replace with your IP address or DNS name

  latency_routing_policy {
    region = "us-west-2"
  }
}

This Terraform code creates two latency-based records for the Z03242191HGJ5WDONGNAD hosted zode in us-east-1 and us-west-2 regions:

For more information, see Terraform: aws_route53_record resource


Health Checks and Latency-Based Routing

  • Health checks can be integrated with latency-based routing to ensure that Route 53 sends requests only to healthy endpoints. If one of your regions is down, Route 53 will automatically exclude it from routing decisions.

Limitations

  1. Latency-based routing only improves network performance, not application processing time.

  2. Not suitable for use cases where traffic should be directed to a specific endpoint (like compliance or regulatory needs).

  3. AWS regions may experience dynamic latency changes based on internet conditions, so results are not always guaranteed to be consistent.


Summary

AWS Route 53’s Latency-Based Routing Policy is an excellent way to ensure low-latency experiences by directing traffic to the nearest and fastest AWS region. It is particularly useful for global applications with users distributed across different geographical locations, such as content delivery systems, real-time gaming platforms, and multi-region web applications.

0
Subscribe to my newsletter

Read articles from Maxat Akbanov directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Maxat Akbanov
Maxat Akbanov

Hey, I'm a postgraduate in Cyber Security with practical experience in Software Engineering and DevOps Operations. The top player on TryHackMe platform, multilingual speaker (Kazakh, Russian, English, Spanish, and Turkish), curios person, bookworm, geek, sports lover, and just a good guy to speak with!