Multi-Region Traffic Routing in AWS: Cost Analysis & Best Solutions

Multi-Region Traffic Routing in AWS: Cost Analysis & Best Solutions

Do you know, you cannot directly route traffic from an AWS Elastic Load Balancer (ELB) to EC2 instances in a different AWS region. ELB only supports routing traffic to resources within the same region where it is deployed, but there are solutions to it. We will discuss the possible solutions and analyze cost involved in each method in this blog.?


Solution 1: Using AWS Global Accelerator

The best AWS-native solution for cross-region traffic distribution is AWS Global Accelerator. It provides a single global static IP address that routes traffic to EC2 instances in different AWS regions with optimized performance.

How It Works:

  1. Set Up AWS Global Accelerator It provides two static IP addresses that act as entry points for your application.
  2. Create Endpoints in Different Regions Add your EC2 instances (via ALB/NLB) in different AWS regions as endpoints.
  3. Route Traffic Based on Latency AWS Global Accelerator intelligently routes requests to the nearest or healthiest endpoint, reducing latency.

Solution 2: Route 53 with Latency-Based Routing (LBR)

  • You can set up Route 53 with LBR to resolve DNS requests to the best region based on user location.

Solution 3: CloudFront + Regional ELBs

  • Deploy CloudFront as a caching layer with origin failover to different regions.?

Here’s a step-by-step AWS CLI-based configuration to set up AWS Global Accelerator for routing traffic across multiple AWS regions.

?

Solution 1: Using AWS Global Accelerator

Step 1: Create an AWS Global Accelerator

Run the following command to create a new accelerator:

aws globalaccelerator create-accelerator \

    --name "MyGlobalAccelerator" \

    --ip-address-type IPV4 \

    --enabled        

Response Example:

{

    "Accelerator": {

        "AcceleratorArn": "arn:aws:globalaccelerator::123456789012:accelerator/abcdef123456",

        "Name": "MyGlobalAccelerator",

        "IpAddressType": "IPV4",

        "Enabled": true,

        "IpSets": [

            {

                "IpFamily": "IPV4",

                "IpAddresses": ["192.0.2.1", "198.51.100.1"]

            }

        ]

    }

}        

Note: The accelerator provides two static IPs (192.0.2.1 and 198.51.100.1) that users will connect to.?

Step 2: Create a Listener

A listener defines the port and protocol the accelerator will listen on.

aws globalaccelerator create-listener \

    --accelerator-arn "arn:aws:globalaccelerator::123456789012:accelerator/abcdef123456" \

    --name "MyListener" \

    --protocol TCP \

    --port-ranges FromPort=80,ToPort=80 \

    --client-affinity NONE        

Response Example:

{

    "Listener": {

        "ListenerArn": "arn:aws:globalaccelerator::123456789012:listener/abcdef123456",

        "Protocol": "TCP",

        "PortRanges": [{"FromPort": 80, "ToPort": 80}]

    }

}        

Step 3: Create an Endpoint Group for Each AWS Region

For each AWS region where you have EC2 instances (or ALBs), create an endpoint group.

aws globalaccelerator create-endpoint-group \

    --listener-arn "arn:aws:globalaccelerator::123456789012:listener/abcdef123456" \

    --endpoint-group-region us-east-1 \

    --traffic-dial-percentage 50

aws globalaccelerator create-endpoint-group \

    --listener-arn "arn:aws:globalaccelerator::123456789012:listener/abcdef123456" \

    --endpoint-group-region us-west-1 \

    --traffic-dial-percentage 50        

Note: traffic-dial-percentage distributes traffic across multiple regions. (50% in each example above)?

Step 4: Add Endpoints (ALB or EC2 Instances)

You can add ALBs, EC2 instances, or NLBs as endpoints.

Option 1: Add an ALB as an Endpoint

aws globalaccelerator add-endpoints \

    --endpoint-group-arn "arn:aws:globalaccelerator::123456789012:endpoint-group/abcdef123456" \

    --endpoint-configurations "EndpointId=arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/MyALB/abcdef,Weight=100"        

Option 2: Add an EC2 Instance as an Endpoint

aws globalaccelerator add-endpoints \

    --endpoint-group-arn "arn:aws:globalaccelerator::123456789012:endpoint-group/abcdef123456" \

    --endpoint-configurations "EndpointId=i-1234567890abcdef0,Weight=100"        

Note: Set the Weight for load distribution.?

Step 5: Verify the Global Accelerator Configuration

aws globalaccelerator list-accelerators        

To check if traffic is being routed, use:

nslookup 192.0.2.1        

or

curl -v https://192.0.2.1?        

AWS Global Accelerator efficiently routes traffic across AWS regions with built-in failover and performance improvements. Let me know if you need more details or troubleshooting help!?

Solution 2: Route 53 with Latency-Based Routing (LBR)

Best For:

  • Routing users to the closest AWS region based on latency.
  • Works with EC2 instances, ALBs, and NLBs.
  • Simple and cost-effective.

Steps to Configure Route 53 LBR:

Step 1: Create a Hosted Zone (if not created)

aws route53 create-hosted-zone \

    --name mydomain.com \

    --caller-reference $(date +%s)        

This creates a DNS zone for mydomain.com.

Step 2: Create Latency-Based Records for Different Regions

For an ALB in us-east-1

aws route53 change-resource-record-sets \

    --hosted-zone-id ZXXXXXXXXXXXXXX \

    --change-batch '{

      "Changes": [{

        "Action": "CREATE",

        "ResourceRecordSet": {

          "Name": "app.mydomain.com",

          "Type": "A",

          "SetIdentifier": "us-east-1",

          "Region": "us-east-1",

          "AliasTarget": {

            "HostedZoneId": "Z35SXDOTRQ7X7K",

            "DNSName": "myalb-1234567890.us-east-1.elb.amazonaws.com",

            "EvaluateTargetHealth": true

          }

        }

      }]

    }'        

Note:

  • Replace ZXXXXXXXXXXXXXX with your hosted zone ID.
  • Z35SXDOTRQ7X7K is the ELB-hosted zone ID for us-east-1 (varies by region).
  • SetIdentifier differentiates regional records.

For an ALB in us-west-1

aws route53 change-resource-record-sets \

    --hosted-zone-id ZXXXXXXXXXXXXXX \

    --change-batch '{

      "Changes": [{

        "Action": "CREATE",

        "ResourceRecordSet": {

          "Name": "app.mydomain.com",

          "Type": "A",

          "SetIdentifier": "us-west-1",

          "Region": "us-west-1",

          "AliasTarget": {

            "HostedZoneId": "Z368ELLRRE2KJ0",

            "DNSName": "myalb-0987654321.us-west-1.elb.amazonaws.com",

            "EvaluateTargetHealth": true

          }

        }

      }]

    }'        

Now, users will be directed to the closest ALB based on latency!?

Solution 3: CloudFront + Regional ELBs

Best For:

  • Routing traffic across regions.
  • Caching content globally for faster access.
  • Works well for websites and APIs.

Steps to Configure CloudFront with Regional ALBs

Step 1: Create a CloudFront Distribution

aws cloudfront create-distribution \

    --origin-domain-name myalb-1234567890.us-east-1.elb.amazonaws.com \

    --default-root-object index.html \

    --enabled \

    --comment "CloudFront with Multi-Region ALB"        

Response:

{

    "Distribution": {

        "Id": "EDFDVBD6EXAMPLE",

        "DomainName": "d1234567890.cloudfront.net"

    }

}        

The generated CloudFront Domain Name (d1234567890.cloudfront.net) will distribute traffic globally.

Step 2: Add a Second Origin (ALB in us-west-1)

To support multiple regions, update the distribution:

aws cloudfront update-distribution \

    --id E1234567890EXAMPLE \

    --default-cache-behavior '{ "TargetOriginId": "us-west-1", "ForwardedValues": { "QueryString": true }, "ViewerProtocolPolicy": "redirect-to-https" }'        

CloudFront will now route traffic to the fastest ALB region!

?

Solution 3?: Multi-Region ALB with Route 53 Failover

Best For:

  • Disaster recovery (automatic failover to another region if the primary fails).
  • Simple setup with active-passive or active-active failover.

Steps to Configure Multi-Region ALB with Failover

Step 1: Create Health Checks for ALBs

aws route53 create-health-check \

    --caller-reference "us-east-1-alb-health" \

    --health-check-config '{

      "IPAddress": "ALB_IP",

      "Port": 80,

      "Type": "HTTP",

      "ResourcePath": "/",

      "RequestInterval": 30,

      "FailureThreshold": 3

    }'        

?? Replace ALB_IP with your ALB's public IP in us-east-1.

?? Repeat this step for us-west-1.

Step 2: Create Failover DNS Records

Primary ALB in us-east-1

aws route53 change-resource-record-sets \

    --hosted-zone-id ZXXXXXXXXXXXXXX \

    --change-batch '{

      "Changes": [{

        "Action": "CREATE",

        "ResourceRecordSet": {

          "Name": "app.mydomain.com",

          "Type": "A",

          "SetIdentifier": "Primary",

          "Failover": "PRIMARY",

          "AliasTarget": {

            "HostedZoneId": "Z35SXDOTRQ7X7K",

            "DNSName": "myalb-1234567890.us-east-1.elb.amazonaws.com",

            "EvaluateTargetHealth": true

          },

          "HealthCheckId": "hc-1234567890"

        }

      }]

    }'        

Secondary ALB in us-west-1 (Failover)

aws route53 change-resource-record-sets \

    --hosted-zone-id ZXXXXXXXXXXXXXX \

    --change-batch '{

      "Changes": [{

        "Action": "CREATE",

        "ResourceRecordSet": {

          "Name": "app.mydomain.com",

          "Type": "A",

          "SetIdentifier": "Secondary",

          "Failover": "SECONDARY",

          "AliasTarget": {

            "HostedZoneId": "Z368ELLRRE2KJ0",

            "DNSName": "myalb-0987654321.us-west-1.elb.amazonaws.com",

            "EvaluateTargetHealth": true

          },

          "HealthCheckId": "hc-0987654321"

        }

      }]

    }'        

?Now, if the us-east-1 ALB fails, traffic will automatically route to us-west-1.

?

Final Thoughts:

?

Which solution do you prefer? Need more details on any??

To analyze the monthly average cost of each multi-region routing solution, let's break down the cost structure for each AWS service involved.?

Cost Analysis by Solution:

?

Cost Breakdown for Each Solution:

1? AWS Global Accelerator

Best for: Ultra-low latency, automatic failover, high availability Cost Breakdown:

  • Global Accelerator $18.25 per month per accelerator
  • $0.025 per GB data transfer out to the internet
  • ALB: $20-$25/month per region (varies by request count)
  • EC2: Depends on instance type

Estimated Monthly Cost:

  • Light traffic (1TB transfer): ~$45 - $80/month
  • High traffic (10TB transfer): ~$250 - $350/month

?

2? Route 53 - Latency-Based Routing

Best for: Cost-efficient, region-aware routing Cost Breakdown:

  • Route 53 DNS hosted zone: $0.50/month
  • DNS queries: $0.40 per million queries
  • ALB: ~$20/month per region
  • EC2: Depends on instance type

Estimated Monthly Cost:

  • Light traffic (5M queries): ~$6 - $10/month
  • Heavy traffic (100M queries): ~$50+/month

?

3? CloudFront + ALB

Best for: Caching & optimizing latency Cost Breakdown:

  • CloudFront Free Tier: 1TB free per month
  • After Free Tier: ~$0.085 per GB
  • ALB: ~$20/month per region
  • EC2: Depends on instance type

Estimated Monthly Cost:

  • Light traffic (1TB via free tier): ~$10/month
  • Heavy traffic (10TB): ~$200+/month

?

4? Multi-Region ALB Failover (Route 53)

Best for: Disaster recovery with automatic failover Cost Breakdown:

  • Route 53 Hosted Zone: $0.50/month
  • Health Checks: ~$1 per check (assume 2 checks)
  • ALB: ~$20/month per region
  • EC2: Depends on instance type

Estimated Monthly Cost:

  • Active-Active Setup: ~$7 - $10/month + ALB & EC2 costs
  • Active-Passive Setup: ~$4 - $7/month + ALB & EC2 costs

?

Final Cost Comparison Summary:

?

?

要查看或添加评论,请登录

Manish Kumar的更多文章

社区洞察