Benchmark chart of Python boto3 TransferConfig throughput, upload duration, and memory utilization across concurrency levels on a 10 GB file upload

When you call <code>s3.upload_file()</code> in Python using default boto3 configurations, transferring a 10 GB database backup or machine learning model often takes nearly ten minutes—even across a dedicated 1 Gbps fiber uplink.

The bottleneck is not your network interface. By default, boto3 uses conservative transfer settings designed for small scripts: low concurrency thresholds, small 8 MB chunks, and a single-threaded queue. The connection spends most of its time idling between TCP acknowledgment roundtrips.

To saturate your available bandwidth, you must tune <code>boto3.s3.transfer.TransferConfig</code>. However, blindly cranking concurrency to 64 threads will exhaust system RAM, cause socket contention, and trigger Out-Of-Memory (OOM) kills on cloud worker instances.

Benchmark results: 10 GB upload across TransferConfig settings

We benchmarked a 10 GB binary fixture (10,737,418,240 bytes) uploaded to an S3-compatible bucket over a symmetrical 1 Gbps network connection (theoretical ceiling ~125 MB/s). We measured wall-clock upload duration, effective transfer rate, peak resident set size (RSS) memory, and CPU utilization across 10 iterations per configuration:

Concurrency (threads)Chunk sizeUpload durationEffective throughputPeak RAM (RSS)CPU load (4 cores)Link saturation
1 thread (Default)8 MB554.0 seconds18.5 MB/s78 MB6%14.8%
2 threads8 MB392.4 seconds26.1 MB/s110 MB9%20.9%
4 threads16 MB212.5 seconds48.2 MB/s175 MB14%38.6%
8 threads16 MB124.0 seconds82.6 MB/s260 MB18%66.1%
16 threads (Optimal)32 MB86.5 seconds118.4 MB/s512 MB24%94.7%
32 threads32 MB85.8 seconds119.3 MB/s980 MB32%95.4%
32 threads (Oversized)64 MB85.2 seconds120.2 MB/s1,840 MB38%96.2%

The data demonstrates clear performance milestones:

  • The 16-thread sweet spot: Increasing concurrency from 1 to 16 threads boosted throughput from 18.5 MB/s to 118.4 MB/s (a 6.4x speedup), slashing upload time from 9.2 minutes to 86.5 seconds.
  • Diminishing returns beyond 16 threads: Jumping from 16 to 32 threads produced less than a 1% throughput gain (118.4 MB/s vs 119.3 MB/s) while doubling memory usage to nearly 1 GB.
  • Memory bloat on 64 MB chunks: Combining 32 threads with 64 MB chunks pushed memory usage to 1.84 GB without any meaningful speed improvement. On a standard 2 GB container runner, this causes instant OOM failures.

Calculating TransferConfig memory bounds

boto3's transfer manager maintains an in-memory queue of chunks ready for transmission. The formula to calculate maximum memory allocation is:

<code>Max Memory = (max_concurrency + max_io_queue) * multipart_chunksize</code>

By default, <code>max_io_queue</code> is set to 100. If you configure <code>multipart_chunksize = 64 * 1024 * 1024</code> (64 MB), boto3 can buffer up to 100 * 64 MB = 6.4 GB of data in memory before waiting for network writes to flush! To maintain tight memory bounds in constrained environments (like Docker containers or Lambda functions), always constrain <code>max_io_queue</code> alongside your thread count.

Production-ready Python benchmark script

Here is the production script used to configure optimized TransferConfig settings with real-time transfer tracking and strict memory ceilings:

import os
import time
import boto3
from boto3.s3.transfer import TransferConfig
from botocore.config import Config

class ProgressPercentage:
    def __init__(self, filename, total_size):
        self._filename = filename
        self._total_size = total_size
        self._seen_so_far = 0
        self._start_time = time.time()

    def __call__(self, bytes_amount):
        self._seen_so_far += bytes_amount
        elapsed = time.time() - self._start_time
        mb_done = self._seen_so_far / (1024 * 1024)
        speed_mb = mb_done / elapsed if elapsed > 0 else 0
        percentage = (self._seen_so_far / self._total_size) * 100
        print(f"\rUploading: {percentage:5.1f}% | {mb_done:7.1f} MB | {speed_mb:5.1f} MB/s", end="", flush=True)

def upload_optimized(file_path: str, bucket: str, key: str):
    file_size = os.path.getsize(file_path)

    # Optimal settings for 1 Gbps uplinks with bounded 512 MB RAM footprint
    config = TransferConfig(
        multipart_threshold=64 * 1024 * 1024,   # 64 MB threshold to trigger multipart
        multipart_chunksize=32 * 1024 * 1024,   # 32 MB chunks (320 parts for 10 GB)
        max_concurrency=16,                     # 16 worker threads
        max_io_queue=16,                        # Limit pending buffer to 16 chunks (512 MB max)
        use_threads=True
    )

    s3_client = boto3.client(
        "s3",
        endpoint_url="https://s3.tport.space",
        config=Config(
            signature_version="s3v4",
            max_pool_connections=32,            # Match connection pool to concurrency
            s3={"addressing_style": "path"}
        )
    )

    print(f"Starting upload: {file_path} ({file_size / (1024**3):.2f} GB) -> s3://{bucket}/{key}")
    start = time.time()
    progress = ProgressPercentage(file_path, file_size)

    s3_client.upload_file(
        Filename=file_path,
        Bucket=bucket,
        Key=key,
        Config=config,
        Callback=progress
    )

    duration = time.time() - start
    mb_transferred = file_size / (1024 * 1024)
    effective_speed = mb_transferred / duration
    print(f"\nUpload complete in {duration:.2f}s ({effective_speed:.2f} MB/s)")

if __name__ == "__main__":
    upload_optimized("/tmp/10gb_payload.dat", "backups", "daily/10gb_payload.dat")

Tip: Notice the max_pool_connections=32 setting in Config. If max_pool_connections is smaller than max_concurrency, worker threads block waiting for available HTTP sockets, negating the benefits of concurrency.

Storage architecture on tport.space

<b>tport.space</b> provides fast S3-compatible object storage designed for high-throughput ingestion pipelines and archival storage with zero egress fees. By tuning TransferConfig to your available network capacity, automated ETL jobs and database backups stream at line rate without paying transit penalties.

Read our related storage and performance benchmarks:

Accelerate your Python S3 pipelines with high-throughput object storage and zero egress fees.

Deploy on tport.space