Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 18: Load Balancing

18.19 One domain name, many regions, many load balancers

Why one name has to hide several balancers

Section 18.11 already showed the limit: one Application Load Balancer does not span regions, and a Mumbai balancer cannot register a Singapore instance. This section is the gap in front of that drawing. Users do not bookmark a balancer's DNS name. They bookmark one name, www.example.com.

An Application Load Balancer or a Network Load Balancer does not have targets in two regions. ap-south-1 (Mumbai) has its own internet-facing Application Load Balancer. eu-west-1 (Ireland) has another. Each has its own DNS name. The names below are examples we made up for the lesson, not live balancers:

  1. mumbai-alb-123.ap-south-1.elb.amazonaws.com
  2. ireland-alb-456.eu-west-1.elb.amazonaws.com

This is not one load balancer with targets in three regions. It is also not cross-zone. Cross-zone is inside one region, one balancer, several Availability Zones. Section 18.18 was that switch. This section is two balancers and one public name.

What Route 53 does with that name

Route 53 is what splits www.example.com. You create one hosted zone for example.com. You create two alias A records, both named www.example.com. Each alias points at a different regional Application Load Balancer. The routing policy is either latency or geolocation. You do not use both on the same name and then guess which one won.

Latency sends the user to the region with the lower latency. Geolocation sends them by the place you configured. The worked example we pick is latency. Geolocation is the second example.

A health check is required for failover. Latency routing does not fail over by itself. On each alias record we turn on Evaluate target health. If the Mumbai balancer has no healthy targets, Route 53 stops returning that record and the user is sent to the other region. A separate Route 53 health check that fails does the same job if you attach it. Without one of those, a dead Mumbai group can still be the answer for a user in Pune.

How latency picks Mumbai or Ireland

Numbers for this lesson, not a measurement we took from a phone.

One name · many regions · latency routing www.example.com Route 53 · Latency Mumbai ALBap-south-1 Ireland ALBeu-west-1 Pune ~20 ms Pune ~150 ms

www.example.com sits above Route 53. Latency routing sends Pune (~20 ms) to the Mumbai ALB and far users toward Ireland (~150 ms from Pune).

User Latency to Mumbai Latency to Ireland Address Route 53 returns
A user in Pune about 20 ms about 150 ms The Mumbai balancer
A user in London higher to Mumbai than to Ireland the lower of the two The Ireland balancer
  1. Both users type www.example.com.
  2. The Pune user's resolver is closer to Mumbai, about 20 ms against about 150 ms, so the answer is mumbai-alb-123.ap-south-1.elb.amazonaws.com.
  3. The London user's answer is ireland-alb-456.eu-west-1.elb.amazonaws.com.
  4. The browser bar shows www.example.com both times.
  5. Each balancer then sends the request only to healthy targets in its own region.

How geolocation picks them instead

Geolocation · labeled boxes (not a real map) www.example.com India → Mumbai ALB Europe → Ireland ALB Default → Mumbai ALB Resolver place, not a phone GPS pin. Same idea as section 18.11.

Geolocation boxes: India → Mumbai ALB, Europe → Ireland ALB, default → Mumbai.

Second example. Same two balancers. The policy is geolocation, not latency.

  1. Record 1: geolocation India, alias to the Mumbai balancer.
  2. Record 2: geolocation Europe, alias to the Ireland balancer.
  3. Default record: alias to the Mumbai balancer, for everyone else.
  4. A query Route 53 places in India receives Mumbai.
  5. A query it places in Europe receives Ireland.
  6. A query it places anywhere else receives the default, Mumbai.
  7. The location is the DNS resolver's place, not a precise pin, same as section 18.11.

How one request walks

Same name · different balancers Pune London Route 53www.example.com Mumbai ALB Ireland ALB Blue (Pune) → Mumbai · purple (London) → Ireland · browser bar still shows www.example.com

A Pune user and a London user both type www.example.com. Route 53 steers them to different regional ALBs.

  1. The browser asks DNS for www.example.com.
  2. Route 53 looks at the two alias records and the user's location.
  3. It returns one balancer address.
  4. The browser connects to that region's internet-facing Application Load Balancer on 443.
  5. That balancer sends the request to a healthy target in that region only.

If Mumbai's targets are unhealthy and Evaluate target health is on, step 3 returns the Ireland address instead. The Ireland balancer still cannot see Mumbai's EC2 instances.

How to create the two alias records

Do this only in a hosted zone you control. Button names may vary. The second region can stay on paper if you have not created the Ireland balancer. Write the name and do not launch extra instances just to finish the form.

  1. Open Route 53.
  2. Create a hosted zone for example.com if you do not already have one.
  3. Choose Create record.
  4. Set the record name to www.
  5. Set the type to A.
  6. Turn on Alias.
  7. Set the alias target to the Mumbai Application Load Balancer. The example name is mumbai-alb-123.ap-south-1.elb.amazonaws.com.
  8. Set the routing policy to Latency.
  9. Set the region to Asia Pacific (Mumbai).
  10. Turn on Evaluate target health.
  11. Save.
  12. Choose Create record again.
  13. Set the record name to www.
  14. Set the type to A.
  15. Turn on Alias.
  16. Set the alias target to the Ireland Application Load Balancer. The example name is ireland-alb-456.eu-west-1.elb.amazonaws.com.
  17. Set the routing policy to Latency.
  18. Set the region to Europe (Ireland).
  19. Turn on Evaluate target health.
  20. Save.
  21. You should see two records, same name www.example.com, different regions.
  22. For the geolocation example, create the records again only after you delete the latency pair. Set the policy to Geolocation, India on the Mumbai record, Europe on the Ireland record, and a default record to Mumbai.
  23. Do not leave both policies in the zone. Delete the records you do not want before class ends.