增加s3连接池

问题描述 投票:0回答:1

我有以下代码:

    client_config = botocore.config.Config(
        max_pool_connections=20
    )
    athena = boto3.client('athena')
    s3 = boto3.resource('s3',config=client_config)
    
    query_result = athena.start_query_execution(
        QueryString = query,
        ResultConfiguration = {
            'OutputLocation': s3_url
        }
    )
    queryExecutionId = query_result['QueryExecutionId']
    response = athena.get_query_execution(QueryExecutionId = queryExecutionId)
    pd.read_csv(f"s3_bucket/{queryExecutionId}.csv")
    
    athena.close() 

它会抛出以下警告:

连接池已满,正在丢弃连接:x.s3.us-west-2.amazonaws.com。连接池大小:10

如何增加 s3 连接的池大小?

谢谢。

python amazon-web-services amazon-s3 boto3 botocore
1个回答
0
投票

关于S3的简短信息

S3 根本不能用作连接池,它的每个部分的限制为每秒 3000 个连接,如果您有很多文件并且需要速度,则需要在部分时使用文件夹结构,例如。

/folder1/ = 3000 connection
/folder2/ = 3000 connection
/folder3/ = 3000 connection
/folder4/ = 3000 connection
/folder5/ = 3000 connection

如果您需要超过 3000 个连接,例如。 folder1 那么你需要再次添加一个像这样的子文件夹

/folder1/a/ = 3000 connection
/folder1/b/ = 3000 connection
/folder1/c/ = 3000 connection

关于雅典娜的简短信息

如果这不是问题,我可以看到您使用 Athena,并且 Athena 查询的限制是同时运行 25 次,请在此处阅读有关 AWS 报价的更多信息 https://docs.aws.amazon.com/athena /latest/ug/service-limits.html

Awsner 为你解答问题

根据 Boto3 文档,您应该能够通过更改

max_pool_connections
配置中的
botocore.config
来更改池大小。

在此处了解更多信息https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

希望它对您的问题有所帮助:)

© www.soinside.com 2019 - 2024. All rights reserved.