Bird
Raised Fist0
AWScloud~5 mins

Routing policies (simple, weighted, latency) in AWS - Commands & Configuration

Choose your learning style10 modes available
Introduction
Routing policies in AWS help decide how internet traffic is directed to your resources. They solve the problem of managing traffic flow to different servers or regions based on simple rules, traffic weights, or connection speed.
When you want all users to go to a single server or resource without any special rules.
When you want to split traffic between two servers, for example, sending 70% to one and 30% to another.
When you want users to connect to the server that responds fastest to reduce delays.
When you are testing a new server and want to send only a small portion of traffic to it.
When you have servers in different regions and want users to connect to the closest one.
Config File - route53-records.json
route53-records.json
{
  "Comment": "Create Route53 records with different routing policies",
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "example.com.",
        "Type": "A",
        "TTL": 60,
        "ResourceRecords": [
          {"Value": "192.0.2.1"}
        ],
        "SetIdentifier": "simple-record"
      }
    },
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "example.com.",
        "Type": "A",
        "TTL": 60,
        "ResourceRecords": [
          {"Value": "192.0.2.2"}
        ],
        "SetIdentifier": "weighted-record-1",
        "Weight": 70
      }
    },
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "example.com.",
        "Type": "A",
        "TTL": 60,
        "ResourceRecords": [
          {"Value": "192.0.2.3"}
        ],
        "SetIdentifier": "weighted-record-2",
        "Weight": 30
      }
    },
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "example.com.",
        "Type": "A",
        "TTL": 60,
        "ResourceRecords": [
          {"Value": "192.0.2.4"}
        ],
        "SetIdentifier": "latency-record-us-east-1",
        "Region": "us-east-1"
      }
    },
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "example.com.",
        "Type": "A",
        "TTL": 60,
        "ResourceRecords": [
          {"Value": "192.0.2.5"}
        ],
        "SetIdentifier": "latency-record-us-west-2",
        "Region": "us-west-2"
      }
    }
  ]
}

This JSON file defines multiple DNS records for the domain example.com using AWS Route53 routing policies.

  • Simple routing: Sends all traffic to 192.0.2.1.
  • Weighted routing: Splits traffic between 192.0.2.2 (70%) and 192.0.2.3 (30%).
  • Latency routing: Sends users to the server with the lowest latency based on their region, either 192.0.2.4 (us-east-1) or 192.0.2.5 (us-west-2).

Each record has a SetIdentifier to distinguish it and TTL to control caching time.

Commands
This command applies the DNS record changes defined in the JSON file to the hosted zone with ID Z3P5QSUBK4POTI. It creates the simple, weighted, and latency routing records.
Terminal
aws route53 change-resource-record-sets --hosted-zone-id Z3P5QSUBK4POTI --change-batch file://route53-records.json
Expected OutputExpected
{ "ChangeInfo": { "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2024-06-01T12:00:00Z", "Comment": "Create Route53 records with different routing policies" } }
→
--hosted-zone-id - Specifies the Route53 hosted zone where records will be changed
→
--change-batch - Points to the JSON file with the record changes
This command lists all DNS records in the hosted zone to verify that the new routing policies were created successfully.
Terminal
aws route53 list-resource-record-sets --hosted-zone-id Z3P5QSUBK4POTI
Expected OutputExpected
{ "ResourceRecordSets": [ { "Name": "example.com.", "Type": "A", "TTL": 60, "SetIdentifier": "simple-record", "ResourceRecords": [{"Value": "192.0.2.1"}] }, { "Name": "example.com.", "Type": "A", "TTL": 60, "SetIdentifier": "weighted-record-1", "Weight": 70, "ResourceRecords": [{"Value": "192.0.2.2"}] }, { "Name": "example.com.", "Type": "A", "TTL": 60, "SetIdentifier": "weighted-record-2", "Weight": 30, "ResourceRecords": [{"Value": "192.0.2.3"}] }, { "Name": "example.com.", "Type": "A", "TTL": 60, "SetIdentifier": "latency-record-us-east-1", "Region": "us-east-1", "ResourceRecords": [{"Value": "192.0.2.4"}] }, { "Name": "example.com.", "Type": "A", "TTL": 60, "SetIdentifier": "latency-record-us-west-2", "Region": "us-west-2", "ResourceRecords": [{"Value": "192.0.2.5"}] } ] }
→
--hosted-zone-id - Specifies the hosted zone to list records from
Key Concept

If you remember nothing else from this pattern, remember: routing policies control how DNS directs users to your servers based on simple rules, traffic weights, or connection speed.

Common Mistakes
Not setting unique SetIdentifier values for each record.
AWS Route53 requires unique identifiers to distinguish records with the same name and type but different routing policies.
Always provide a unique SetIdentifier for each routing policy record.
Using the same Weight value for weighted routing records.
Weights determine traffic split; identical weights cause equal traffic distribution, which may not be intended.
Assign different Weight values to control traffic percentages properly.
Omitting the Region field in latency routing records.
Latency routing depends on the Region to route users to the closest server; missing this causes routing failure.
Specify the Region for each latency routing record.
Summary
Create DNS records with different routing policies using a JSON change batch file.
Apply the changes to your Route53 hosted zone with the AWS CLI.
Verify the records were created correctly by listing them in the hosted zone.

Practice

(1/5)
1. What does a simple routing policy do in AWS Route 53?
easy
A. Sends all traffic to a single resource
B. Splits traffic based on weights
C. Routes traffic based on lowest latency
D. Routes traffic randomly among resources

Solution

  1. Step 1: Understand simple routing purpose

    Simple routing sends all user requests to one resource without splitting or conditions.
  2. Step 2: Compare with other routing types

    Weighted routing splits traffic, latency routing chooses fastest server, so they differ from simple routing.
  3. Final Answer:

    Sends all traffic to a single resource -> Option A
  4. Quick Check:

    Simple routing = single destination [OK]
Hint: Simple routing means one destination for all traffic [OK]
Common Mistakes:
  • Confusing simple routing with weighted routing
  • Thinking simple routing balances traffic
  • Assuming simple routing uses latency
2. Which of the following is the correct way to configure a weighted routing policy in AWS Route 53?
easy
A. Assign weights to each record to split traffic
B. Set a single IP address for all traffic
C. Use latency measurements to route traffic
D. Randomly assign traffic without weights

Solution

  1. Step 1: Identify weighted routing configuration

    Weighted routing requires assigning numeric weights to DNS records to control traffic distribution.
  2. Step 2: Eliminate incorrect options

    Single IP is simple routing, latency routing uses latency, random without weights is invalid.
  3. Final Answer:

    Assign weights to each record to split traffic -> Option A
  4. Quick Check:

    Weighted routing = assign weights [OK]
Hint: Weighted routing needs numeric weights per record [OK]
Common Mistakes:
  • Confusing weighted with simple routing
  • Using latency instead of weights
  • Not assigning any weight values
3. Given two servers in different regions with latency routing enabled, which server will Route 53 direct a user to?
medium
A. The server with the highest weight
B. The server with the lowest latency from the user
C. The server with the most traffic
D. The server randomly chosen

Solution

  1. Step 1: Understand latency routing behavior

    Latency routing sends users to the server with the lowest network delay from their location.
  2. Step 2: Exclude other options

    Weight is for weighted routing, traffic volume is not a factor, random choice is not latency routing.
  3. Final Answer:

    The server with the lowest latency from the user -> Option B
  4. Quick Check:

    Latency routing = fastest server [OK]
Hint: Latency routing picks fastest server by user location [OK]
Common Mistakes:
  • Mixing weighted and latency routing concepts
  • Assuming traffic volume affects routing
  • Thinking routing is random
4. You configured weighted routing but all traffic still goes to one server. What is the most likely cause?
medium
A. DNS records have different names
B. Latency routing is enabled instead of weighted
C. Simple routing policy is selected by mistake
D. Weights are set to zero for other servers

Solution

  1. Step 1: Check weight values in weighted routing

    If weights for other servers are zero, all traffic goes to the server with non-zero weight.
  2. Step 2: Rule out other causes

    Latency routing or simple routing would behave differently; different record names do not affect routing weights.
  3. Final Answer:

    Weights are set to zero for other servers -> Option D
  4. Quick Check:

    Zero weights = no traffic [OK]
Hint: Check weights are not zero for all servers [OK]
Common Mistakes:
  • Confusing routing policy type
  • Ignoring zero weights effect
  • Assuming DNS names affect weighted routing
5. You want to route 70% of traffic to a primary server and 30% to a backup server, but also ensure users connect to the lowest latency server within those groups. Which routing policy setup should you use?
hard
A. Use latency routing only with weights assigned
B. Use simple routing with latency routing
C. Use weighted routing with latency routing inside each weight group
D. Use weighted routing only without latency

Solution

  1. Step 1: Understand combined routing needs

    You want to split traffic by weight, then route users to lowest latency server within each group.
  2. Step 2: Identify correct routing policy combination

    Weighted routing controls traffic percentage, latency routing directs users to fastest server inside each weighted group.
  3. Step 3: Eliminate incorrect options

    Simple routing cannot split traffic; latency routing alone can't assign weights; weighted routing alone ignores latency.
  4. Final Answer:

    Use weighted routing with latency routing inside each weight group -> Option C
  5. Quick Check:

    Combine weighted + latency for split and speed [OK]
Hint: Combine weighted and latency routing for split and speed [OK]
Common Mistakes:
  • Trying to use simple routing for traffic split
  • Ignoring latency inside weighted groups
  • Assuming latency routing can split traffic by weight
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard