- Sarthak's Newsletter
- Posts
- Boosting Performance with Latency-Based Routing and AWS Global Accelerator
Boosting Performance with Latency-Based Routing and AWS Global Accelerator
Distance affects performance, going further away latency can easily reach a third or half of a second for a round-trip. This could be a bummer when you serve customers globally. Luckily there’s..
Global Accelerator
AWS Global Accelerator is a powerful solution that addresses several common DNS issues. One of the main benefits of using Global Accelerator is that it eliminates the need for relying on IP address caches, which can be slow and unreliable. Instead, it offers two static IPv4 addresses that act as a single entry-point for users to connect through. Furthermore, there's no DNS configuration for you to maintain, which simplifies the process and reduces the risk of errors.
The two static IPv4 addresses are hosted in independent network zones that provide fault tolerance. Like an Availability Zone (AZ), a network zone is an isolated unit with its own set of physical infrastructure. When you configure an accelerator, if one IPv4 address from a network zone becomes unavailable due to IP address blocking by certain client networks or network disruptions, then client applications can retry on the healthy static IP address from the other isolated network zone.
The IPv4 addresses are announced from AWS's globally distributed edge locations, allowing traffic to enter the AWS Backbone network, which is faster than routing traffic via the public internet. Global Accelerator uses BGP (Border Gateway Protocol) Anycast to route traffic over multiple paths (edge locations) to its destination. Essentially, a BGP announcement is a way for routers to announce to other routers that they are able and willing to receive traffic for certain IP addresses. Every time a packet moves from one router to another system, it's called a hop, and every hop costs processing time, so fewer hops mean lower latency.
It's important to note that the AWS Backbone network is very efficient and has dedicated fiber lines that allow for fewer hops between countries and continents. Instead of using your local ISP to route all the way to a certain address, you'll use your local ISP to connect to the edge location, which reduces latency and the risk of network failures. Ultimately, Global Accelerator routes your traffic over the most optimal edge location path towards its destination, providing a seamless and reliable experience for your customers.
Latency-Based Routing vs Geolocation-Based Routing in AWS Route 53
Route 53 is a highly available and scalable cloud Domain Name System (DNS) web service provided by AWS. One of its routing policies is latency-based routing, which can direct your users to the lowest-latency AWS endpoint available based on their geographic location. This routing policy is useful in active-active architecture scenarios where your stack spans multiple regions, which can be done for disaster recovery and/or latency advantages.
For example, let's say you have a web application running in both the Ireland and Mumbai regions. If you enable latency-based routing and a user in Amsterdam accesses your website, they will likely be directed to the eu-west-1 region since it has the lowest latency based on network conditions of the past X weeks. Similarly, a user in Japan will likely be directed to the ap-south-1 region.
However, if there are compliance requirements that dictate where customer data should be stored, latency-based routing may not be sufficient. For instance, let's say that Irish customer data should be stored in the Ireland region, while Mumbai customer data should be stored in the Mumbai region. In this case, geolocation-based routing would be more appropriate.
Geolocation-based routing allows Route 53 to route traffic to resources based on the geographic location of the source query. This means that if a user in Amsterdam accesses your website, they will be directed to the Ireland region since that's where the Irish customer data is stored, while a user in Japan will be directed to the Mumbai region.
In summary, while latency-based routing is useful for directing users to the lowest-latency AWS endpoint available based on their location, it may not be sufficient for scenarios where compliance requirements dictate where customer data should be stored. In such cases, geolocation-based routing can be used to ensure that traffic is routed to the appropriate region based on the geographic location of the source query.
When to choose which?
Route 53 Latency-Based Routing uses DNS telemetry and network latency to determine the best latency record for a given query. It spends more time on the ISP network and the Internet, making it a good option for architectures with many different regions. However, it may not perform as well as Global Accelerator for architectures with just a few regions.
AWS Global Accelerator spends more time on the AWS Backbone network, which can provide better performance for architectures with just a few regions. It also offers static IPv4 addresses, which can be hardcoded in DNS and firewall configurations for improved fault tolerance. Global Accelerator performs TLS termination at the edge, allowing for faster 3-way handshake processes.
It's important to note that BGP Anycast, which is used by Global Accelerator, can be slow to respond to network events such as link failures. Route 53 uses DNS health checks to respond to network events, which are often faster than BGP Anycast.
In summary, when choosing between Route 53 Latency-Based Routing and AWS Global Accelerator, consider the distance between clients and resources, the number of regions in your stack, and the need for fault tolerance. For architectures with many regions, Route 53 may be the preferred option, while Global Accelerator may perform better for architectures with just a few regions.
Readings
AWS created a tool to compare Global Accelerator to the public internet.
A nice session to learn more about Global Accelerator is this Re:Invent 2020 NET311 session.