为什么 amazon S3 客户端依赖于位置?
Why is amazon S3 clients location dependents?
我在玩amazon-s3
。我的用例是仅列出以前缀开头的键。
import boto3
s3 = boto3.client('s3', "eu-west-1")
response = s3.list_objects_v2(Bucket="my-bucket", MaxKeys=1, Prefix="my/prefix/")
for content in response['Contents']:
print(content['Key'])
my-bucket
位于 use1
。我很惊讶来自 euw1
的 python 客户能够执行此类请求。作为参考,我的 Scala 客户端:
val client = AmazonS3ClientBuilder.standard().build()
client.listObjectsV2("my-bucket", "my-prefix")
给出错误
com.amazonaws.services.s3.model.AmazonS3Exception: The bucket is in this region: us-east-1. Please use this region to retry the request
这是预期的。
我的问题是,为什么 s3Client 依赖于位置?选择正确的位置有什么好处吗?不匹配位置是否有任何隐藏费用?
My question is, why the s3Client is location dependant
因为桶是区域资源,即使他们假装不是。尽管 S3 存储桶可在全球范围内访问,但底层资源仍托管在特定的底层 AWS 区域中。如果您使用 AWS 客户端 sdks 访问资源,则需要连接到存储桶的区域 S3 端点。
Is there any advantage to choose the right location?
延迟更低。如果您的服务在 eu-west-1
中,那么将您的存储桶也放在那里是有意义的。您也不会支付 cross-region 数据传输费率,而是 AWS 的内部区域费率。
Is there any hidden cost to not match the location?
是的。数据传出的费用因地区而异,从一个地区向另一地区发送数据比在同一地区的服务之间发送数据要支付更多费用。
至于为什么 boto3 库没有引发错误,它可能在发出 list_objects_v2
调用之前询问引擎盖下的 S3 api 以确定存储桶的位置。
我在玩amazon-s3
。我的用例是仅列出以前缀开头的键。
import boto3
s3 = boto3.client('s3', "eu-west-1")
response = s3.list_objects_v2(Bucket="my-bucket", MaxKeys=1, Prefix="my/prefix/")
for content in response['Contents']:
print(content['Key'])
my-bucket
位于 use1
。我很惊讶来自 euw1
的 python 客户能够执行此类请求。作为参考,我的 Scala 客户端:
val client = AmazonS3ClientBuilder.standard().build()
client.listObjectsV2("my-bucket", "my-prefix")
给出错误
com.amazonaws.services.s3.model.AmazonS3Exception: The bucket is in this region: us-east-1. Please use this region to retry the request
这是预期的。
我的问题是,为什么 s3Client 依赖于位置?选择正确的位置有什么好处吗?不匹配位置是否有任何隐藏费用?
My question is, why the s3Client is location dependant
因为桶是区域资源,即使他们假装不是。尽管 S3 存储桶可在全球范围内访问,但底层资源仍托管在特定的底层 AWS 区域中。如果您使用 AWS 客户端 sdks 访问资源,则需要连接到存储桶的区域 S3 端点。
Is there any advantage to choose the right location?
延迟更低。如果您的服务在 eu-west-1
中,那么将您的存储桶也放在那里是有意义的。您也不会支付 cross-region 数据传输费率,而是 AWS 的内部区域费率。
Is there any hidden cost to not match the location?
是的。数据传出的费用因地区而异,从一个地区向另一地区发送数据比在同一地区的服务之间发送数据要支付更多费用。
至于为什么 boto3 库没有引发错误,它可能在发出 list_objects_v2
调用之前询问引擎盖下的 S3 api 以确定存储桶的位置。