英文:
How to route requests regionally through Amazon Route53?
问题
我有3个相同的Web服务器分布在北美(NA)、欧洲(EU)和亚洲(Asia)这3个主要地区。响应时间对这个系统至关重要,因此,我希望将对这个Web服务器的请求路由到距离请求源最近的实例。如何在Amazon Route53上的DNS级别实现这一点?
我尝试过的方法
- 我尝试创建一个包含所有3个IP地址的
ResourceRecordSet
,但是我只能为每个ResourceRecordSet
设置一个GeoLocation
。 - 我尝试创建3个
ResourceRecordSet
,将它们的GeoLocation.ContinentCode
分别设置为NA
、EU
和AS
,并将它们的ResourceRecords
设置为相应的IP地址。然而,无论请求的来源如何,所有发送到该域的请求都被路由到相同的实例。
英文:
I have 3 identical web servers in 3 major regions NA, EU, and Asia. The response time is crucial for this system, therefore, I want the requests to this web server to be routed to the closest instance to the request source. How do I achieve this on the DNS level using Amazon Route53?
What I tried
- I tried to create a
ResourceRecordSet
with itsResourceRecords
containing all 3 IP addresses. However, I can set oneGeoLocation
perResourceRecordSet
. - I tried to create 3
ResourceRecordSet
with theirGeoLocation.ContinentCode
set toNA
,EU
, andAS
and theirResourceRecords
set to corresponding IP addresses. However, all requests sent to the domain were routed to the same instance, regardless of the request origin.
答案1
得分: 3
Your requirements seem to match Latency-based routing - Amazon Route 53. This will route users via the connection with the lowest latency, which might not be the closest location geographically due to the placement of high-speed internet connections. You could then use something like Global Latency Test - Bunny Tools to test how it behaves.
To configure Latency-Based Routing:
- Create 3 records with the same Record Name
- Select a Routing Policy of Latency
- For each resource, select the Region where the target is located -- it will route based on the latency from the user requesting the DNS resolution to the selected Region
- It also wants a Record ID that is simply your reference for the target
You can even create these multiple records on a single page by clicking Add Another Record at the bottom of the screen.
To configure the Record Sets via an API call, consult the documentation for your preferred AWS SDK. For example, here is a change_resource_record_sets - Boto3 documentation example for boto3/Python:
response = client.change_resource_record_sets(
ChangeBatch={
'Changes': [
{
'Action': 'CREATE',
'ResourceRecordSet': {
'HealthCheckId': 'abcdef11-2222-3333-4444-555555fedcba',
'Name': 'example.com',
'Region': 'us-east-2',
'ResourceRecords': [
{
'Value': '192.0.2.44',
},
],
'SetIdentifier': 'Ohio region',
'TTL': 60,
'Type': 'A',
},
},
{
'Action': 'CREATE',
'ResourceRecordSet': {
'HealthCheckId': 'abcdef66-7777-8888-9999-000000fedcba',
'Name': 'example.com',
'Region': 'us-west-2',
'ResourceRecords': [
{
'Value': '192.0.2.45',
},
],
'SetIdentifier': 'Oregon region',
'TTL': 60,
'Type': 'A',
},
},
],
'Comment': 'EC2 instances for example.com',
},
HostedZoneId='Z3M3LMPEXAMPLE',
)
print(response)
Or, for the equivalent in the AWS CLI, see: change-resource-record-sets — AWS CLI Command Reference
英文:
Your requirements seem to match Latency-based routing - Amazon Route 53. This will route users via the connection with the lowest latency, which might not be the closest location geographically due to the placement of high-speed internet connections. You could then use something like Global Latency Test - Bunny Tools to test how it behaves.
To configure Latency-Based Routing:
- Create 3 records with the same Record Name
- Select a Routing Policy of Latency
- For each resource, select the Region where the target is located -- it will route based on the latency from the user requesting the DNS resolution to the selected Region
- It also wants a Record ID that is simply your reference for the target
You can even create these multiple records on a single page by clicking Add Another Record at the bottom of the screen.
To configure the Record Sets via an API call, consult the documentation for your preferred AWS SDK. For example, here is a change_resource_record_sets - Boto3 documentation example for boto3/Python:
response = client.change_resource_record_sets(
ChangeBatch={
'Changes': [
{
'Action': 'CREATE',
'ResourceRecordSet': {
'HealthCheckId': 'abcdef11-2222-3333-4444-555555fedcba',
'Name': 'example.com',
'Region': 'us-east-2',
'ResourceRecords': [
{
'Value': '192.0.2.44',
},
],
'SetIdentifier': 'Ohio region',
'TTL': 60,
'Type': 'A',
},
},
{
'Action': 'CREATE',
'ResourceRecordSet': {
'HealthCheckId': 'abcdef66-7777-8888-9999-000000fedcba',
'Name': 'example.com',
'Region': 'us-west-2',
'ResourceRecords': [
{
'Value': '192.0.2.45',
},
],
'SetIdentifier': 'Oregon region',
'TTL': 60,
'Type': 'A',
},
},
],
'Comment': 'EC2 instances for example.com',
},
HostedZoneId='Z3M3LMPEXAMPLE',
)
print(response)
Or, for the equivalent in the AWS CLI, see: change-resource-record-sets — AWS CLI Command Reference
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论