How it works β
CargoShip turns a directory on disk into a set of compressed archive objects in S3, plus a manifest that records exactly where every file went. Understanding the pipeline makes every other page β flags, costs, restores β easier to reason about.
The streaming pipeline β
An upload flows through four stages, connected by in-memory pipes (io.Pipe) rather than temporary files on disk:
ββββββββββββ ββββββββββββ βββββββββββββ ββββββββββββ
β Scanner ββββΆβ Chunker ββββΆβ Archiver ββββΆβ Uploader ββββΆ S3
ββββββββββββ ββββββββββββ βββββββββββββ ββββββββββββ
walk files group into tar + zstd parallel,
+ detect chunks & per chunk multi-prefix
metadata shards PutObject- Scanner walks the source directory, collecting each file's path, size, modification time, and (optionally) a content hash and AI-detected type.
- Chunker groups files into chunks β the unit that becomes one S3 object β and assigns each chunk to a shard (an S3 key prefix) for parallelism.
- Archiver streams each chunk into a
tarcontainer, compressing with Zstandard at a level chosen for the chunk's content type. - Uploader sends chunks to S3 concurrently, spread across shard prefixes, and records the result in the manifest.
Because stages are connected by pipes, a chunk is being uploaded while the next one is still being archived and the scanner is still walking β nothing waits for the whole dataset, and nothing is staged to local disk. Memory use is bounded by roughly chunk_size Γ workers, not by the dataset size.
What lands in S3 β
A completed upload has a predictable layout under a single upload ID:
s3://my-bucket/archives/uploads/20260721-a1b2c3/
βββ manifest.json.gz # the index of everything
βββ shard-0/
β βββ chunk-0.tar.zst
β βββ chunk-8.tar.zst
βββ shard-1/
β βββ chunk-1.tar.zst
β βββ chunk-9.tar.zst
βββ β¦ (shards 2..N)- Each chunk is a standard
tar.zstobject (or plain.tarwhen its contents are already-compressed formats). - Chunks are spread across shards (
shard-0,shard-1, β¦) so uploads and restores parallelize across S3 prefixes. - The manifest is a JSON document mapping every original file to its chunk, shard, and S3 key, along with sizes, hashes, and compression details.
This layout is a documented, open format β see the Archive & Manifest Format Spec. You can extract your data with standard tar/zstd tooling even if CargoShip isn't installed.
Why sharding matters β
S3 scales request throughput per key prefix. By writing chunks under multiple prefixes (shard-0, shard-1, β¦) instead of one, CargoShip parallelizes the request rate rather than serializing through a single prefix. The shard count is chosen adaptively (4β32) from the workload's file count, size, and your machine's resources β or you can set it manually.
The manifest is the source of truth β
Every later operation reads the manifest:
cargoship list/infoβ see what's in an upload without downloading.cargoship verifyβ check integrity against recorded checksums.cargoship restore/downloadβ pull specific files back, resolving each to its chunk and shard.cargoship shell/browseβ navigate the archive interactively.
Next β
You have the mental model. Now get a working upload:
- Quick Start β zero to a verified upload in minutes.
- Concepts & terminology β precise definitions of upload ID, chunk, shard, manifest, and more.
