
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 size | Upload duration | Effective throughput | Peak RAM (RSS) | CPU load (4 cores) | Link saturation |
|---|---|---|---|---|---|---|
| 1 thread (Default) | 8 MB | 554.0 seconds | 18.5 MB/s | 78 MB | 6% | 14.8% |
| 2 threads | 8 MB | 392.4 seconds | 26.1 MB/s | 110 MB | 9% | 20.9% |
| 4 threads | 16 MB | 212.5 seconds | 48.2 MB/s | 175 MB | 14% | 38.6% |
| 8 threads | 16 MB | 124.0 seconds | 82.6 MB/s | 260 MB | 18% | 66.1% |
| 16 threads (Optimal) | 32 MB | 86.5 seconds | 118.4 MB/s | 512 MB | 24% | 94.7% |
| 32 threads | 32 MB | 85.8 seconds | 119.3 MB/s | 980 MB | 32% | 95.4% |
| 32 threads (Oversized) | 64 MB | 85.2 seconds | 120.2 MB/s | 1,840 MB | 38% | 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:
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:
- Stream database dumps directly into multipart uploads without local disk storage in Automated daily MySQL and PostgreSQL backups directly to S3: streaming pg_dump with zero disk spill (
/articles/stream-pg-dump-mysqldump-s3-zero-disk-spill). - Evaluate checksum overhead across CRC32 and SHA-256 during high-throughput uploads in S3 client checksum algorithms compared (
/articles/s3-client-checksum-algorithms-crc32-sha256-cpu-overhead). - Understand the 10,000 part ceiling and chunk calculations in Multipart uploads: which part size for 5 GB, 50 GB and 500 GB files (
/articles/multipart-part-size-5gb-50gb-500gb).
Accelerate your Python S3 pipelines with high-throughput object storage and zero egress fees.
Deploy on tport.space