该问题是由于AWS S3的多段上传在上传时打开了多个TCP连接,从而导致了连接数的增加。 可以通过在代码中设置最大可用TCP连接数来限制连接数量。
Python示例代码:
import boto3
from botocore.config import Config
# 限制TCP连接数为4
config = Config(max_pool_connections=4)
s3_client = boto3.client('s3', config=config)
# 在多段上传时使用S3 Transfer Manager,它会自动利用此配置中的最大TCP连接数
transfer_config = boto3.s3.transfer.TransferConfig(max_concurrency=4)
s3_transfer = boto3.s3.transfer.S3Transfer(s3_client, transfer_config)
# 通过S3 Transfer Manager进行多段上传,并管理TCP连接数量
s3_transfer.upload_file("large_file.mp4", "my_bucket", "large_file.mp4")