admin管理员组文章数量:1401636
I have code that creates few S3 objects but for many access keys. It does so in parallel, but within the same python process.
Each of the boto3 instances has its own connection pool, which can linger even when it is not used. What happens, on occassion, is that the whole thing crashes with some variant of this error:
[Errno 99] Cannot assign requested address
This is because there is simply too many TCP connections on the system. This limit can be altered, but I am hitting up to 27000 connections.
This is how I instantiate boto3:
my_boto_resource = boto3.resource(service_name='s3',
use_ssl=False,
verify=False,
region_name='us-east-1',
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
endpoint_url=";)
my_boto_client = self.resource.meta.client
These two then get passed to code that populates some test data on for all S3 access keys. Note that the endpoint URL is always the same, it's a custom S3 server that supports unlimited access keys.
I had faced the exact same problem in JavaScript with the @aws-sdk/client-s3
library. But that library allows you to construct S3
instances with pre-created http(s)
agent object, which can then be shared across many instances.
Is there some way to share HTTP(s) connection pool for the same host for boto3 instances, like in @aws-sdk/client-s3
?
Note: Reducing how many S3 access keys are being processed in parallel has been tried. However, due to very small number of operations per S3 key (sometime just one), this reduced the speed of the whole script significantly.
版权声明:本文标题:python - Can I get different boto3 instances to share their connection pool to the same host? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744252531a2597318.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论