The AWS SDK for JavaScript v3 gives you <code>Upload</code> from <code>@aws-sdk/lib-storage</code> for big files: it cuts a stream into parts and sends several at once. Two settings decide how much memory that costs, <code>partSize</code> (default 5 MiB) and <code>queueSize</code> (default 4). The docs say only that a higher queue size uses more memory. We measured how much: nine combinations, three runs each, a 2 GiB upload, peak RSS and event-loop delay.
Short answer: peak memory is about 2 to 4 times the part-size x concurrency sum for parts of 16 MiB and up (more for 5 MiB parts, where Node's own overhead dominates), on top of the 34 MiB Node starts at. 10 parts of 64 MiB took 1.35 GiB of RSS to move 2 GiB. 4 parts of 16 MiB took about 290 MiB and finished in the same 15 seconds as 4 parts of 64 MiB.
What we tested
- Machine: Mac mini, 10 cores, 16 GB, macOS 27.2, Node.js v22.23.4,
@aws-sdk/client-s3and@aws-sdk/lib-storage3.1179.0. - Source: a Readable stream of 2,048 chunks of 1 MiB (2 GiB), passed as
Body. Streams are what you use when the file does not fit in memory. - Sink: a separate local Node process that speaks just enough S3 (CreateMultipartUpload, UploadPart, CompleteMultipartUpload), throws the bytes away and paces each part request to 40 MB/s, like a connection to a storage endpoint over the internet. So one upload at queueSize 1 is capped at 40 MB/s and queueSize 4 at 160 MB/s.
- Measured in the client process: peak RSS (sampled every 50 ms and checked against the OS maximum), heap, event-loop delay with
perf_hooks.monitorEventLoopDelay(10 ms resolution). One fresh process per run, runs back to back, 3 runs per cell. - Not tested: a real network or a live bucket. Client memory does not depend on the server, but the speeds below belong to our 40 MB/s sink, not to your link.
How Upload holds memory
Reading the source of <code>lib-storage</code> 3.1179.0 explains the numbers. <code>queueSize</code> workers share one chunk generator. Each worker takes a part, sends it and waits before taking the next, so at most queueSize parts are in flight. When the body is a stream the generator collects incoming chunks until it has more than <code>partSize</code> bytes, joins them with <code>Buffer.concat</code> (a copy) and slices off one part; the remainder stays referenced as the start of the next. So the live memory is the parts being sent, the part being assembled, and the copies the SDK makes while signing and chunk-encoding the request body. That is why the cost is a multiple of the sum, not the sum.
| queueSize | partSize (MiB) | Sum (MiB) | Peak RSS, 3 runs (MiB) | Above the 34 MiB baseline (x sum) | Loop delay p99 (ms) | Loop delay max (ms) | Average speed (MB/s) |
|---|---|---|---|---|---|---|---|
| 1 | 5 | 5 | 110 to 117 | 83 (16.6x) | 20.3 to 22 | 25.1 to 95.6 | 38 |
| 1 | 16 | 16 | 144 to 148 | 111 (6.9x) | 27.8 to 29 | 36 to 38.9 | 38 |
| 1 | 64 | 64 | 263 to 267 | 231 (3.6x) | 12.7 to 16 | 76.8 to 102.5 | 39 |
| 4 | 5 | 20 | 155 to 185 | 133 (6.7x) | 13.3 to 25.7 | 14.8 to 38.2 | 140 |
| 4 | 16 | 64 | 270 to 291 | 257 (4.0x) | 30.2 to 60.6 | 48.7 to 71.2 | 141 |
| 4 | 64 | 256 | 590 to 593 | 557 (2.2x) | 32.7 to 65.2 | 117.6 to 267.6 | 145 |
| 10 | 5 | 50 | 260 to 264 | 227 (4.5x) | 22.5 to 38.3 | 34.5 to 43.3 | 343 |
| 10 | 16 | 160 | 475 to 531 | 449 (2.8x) | 89.8 to 98.2 | 97.2 to 109.8 | 317 |
| 10 | 64 | 640 | 1354 to 1358 | 1321 (2.1x) | 25.8 to 68.7 | 407.6 to 444.3 | 268 |
The sink paces each connection at 40 MB/s, so queueSize 1 can never beat 40 MB/s, and queueSize 4 sits at about 140 MB/s because the SDK needs time to build each part. Heap stayed at 11 to 14 MiB in every run: the parts are Buffers outside the JavaScript heap, so a heap graph will not show the problem. Watch RSS.
What the table says
- Part size drives memory more than queue size at the same sum. 4 x 16 MiB and 1 x 64 MiB both sum to 64 MiB but use about 290 and 265 MiB; the first is about 3.6 times faster.
- Past about 4 workers on a 40 MB/s per-connection link, you only buy speed. queueSize 10 with 5 MiB parts reached 343 MB/s on 260 MiB of RSS; queueSize 4 with 5 MiB parts used 155 to 185 MiB for 140 MB/s.
- Big parts do not help when the link is the limit. At queueSize 10, 64 MiB parts ran slower (268 MB/s) than 5 MiB parts (343 MB/s) and used 1,355 MiB, because a 64 MiB part takes the sink 1.6 s to accept and the last parts finish late.
- Event-loop stalls grow with part size. The worst single stall was up to 268 ms with 64 MiB parts at queueSize 4 and up to 444 ms at queueSize 10, against 15 to 43 ms with 5 MiB parts at the same queue sizes. Building a 64 MiB Buffer blocks the loop. If the same process serves HTTP requests, that is a latency spike for every client.
- The default (4 x 5 MiB) is a sound choice: 155 to 185 MiB RSS, p99 delay about 25 ms. Change it only with a reason.
Choosing the values
Part size has a floor and a ceiling you can compute. S3 allows at most 10,000 parts, and <code>lib-storage</code> throws when it would go over, so the largest object with 5 MiB parts is 50,000 MiB (about 48.8 GiB). For a stream of unknown length, pick <code>partSize = ceil(max file size / 10,000)</code>, never below 5 MiB. A 500 GiB file needs parts of at least 52 MiB, and the table says 4 parts of 64 MiB cost about 590 MiB of RSS, so expect 550 MiB or so. The <a href="https://tport.space/articles/multipart-upload-part-size-5gb-50gb-500gb">part-size table for 5 GB, 50 GB and 500 GB files</a> has the same sum from the request side.
| File size | Smallest partSize | queueSize 4 peak RSS (estimate) |
|---|---|---|
| 10 GiB | 5 MiB | about 170 MiB (measured: 4 x 5 MiB gave 155 to 185) |
| 100 GiB | 11 MiB (102,400 MiB / 10,000, rounded up) | about 220 MiB (between our 4 x 5 and 4 x 16 cells) |
| 500 GiB | 52 MiB | about 550 MiB (4 x 64 MiB measured 590) |
The memory column is read off or interpolated from our cells, so treat the 11 and 52 MiB rows as estimates; we did not run those sizes. If you run several uploads at once, multiply by the number of uploads: each <code>Upload</code> has its own queue.
Setting it, and a failed upload
<code>leavePartsOnError: false</code> is the default: on failure the SDK sends AbortMultipartUpload. A killed process cannot, so parts stay; see <a href="https://tport.space/articles/abort-incomplete-multipart-uploads-s3-cost-script">how to find and abort abandoned multipart uploads</a>. For the single-stream case without <code>Upload</code>, see <a href="https://tport.space/articles/nodejs-s3-upload-streaming-backpressure-pipeline-vs-manual-chunking-memory-event-loop">streaming 8 GiB from Node.js</a>.
S3-compatible object storage with no egress fees: the same @aws-sdk/lib-storage code works against one endpoint.
Explore tport.spaceTest record and sources
- Run on 29 November 2026, Mac mini (10 cores, 16 GB, macOS 27.2), Node.js v22.23.4, loopback only. 9 combinations x 3 runs, 2 GiB each, the body a repeated byte (no compression involved), sink paced at 40 MB/s per part request.
- Limits: a local sink, not a live bucket; one machine; Node 22; a stream body (a Buffer body or a file path would hold different amounts). RSS includes about 34 MiB of Node itself, measured before the upload starts. The 64 MiB cells are the ones to treat as a guide, not a promise: macOS decides when freed memory is returned.
- Source of
@aws-sdk/lib-storage3.1179.0 (getChunkStream, thequeueSizeworkers, defaults of 4 and 5 MiB, the 10,000-part cap) and its README on npm. AWS S3 multipart upload limits (5 MiB minimum part, 10,000 parts) in the Amazon S3 User Guide. Node.jsperf_hooks.monitorEventLoopDelaydocs. aws-sdk-js-v3 issue #5730 (a browser upload with queueSize 4 and 5 MB parts running out of memory on a 112 GB file). - Benchmark scripts and raw results:
scripts/bench/node-lib-storage/in the content repository.