Media & storage: build a chunked, deduplicated upload-and-sync service
Hands-on project: build a small file service that uploads bytes direct to object storage, splits files into content-addressed chunks for delta sync and dedup, stores metadata separately, and resolves conflicts via a version chain — the spine of every design in this unit.
Reading that “bytes go to object storage and you sync deltas via content-addressed chunks” is not the same as building a service that actually does it. Build a small but real upload-and-sync service: bytes never touch your app server’s data path, files are stored as deduplicated chunks, an edit syncs only the changed chunks, and two conflicting edits both survive. When you’re done you’ll have implemented, in miniature, the spine shared by YouTube, Drive, and S3.
This project makes the unit operational. You’ll separate the control path from the data path, implement content-addressed chunking and measure the delta-sync and dedup wins, store metadata apart from bytes, and prove that the version chain prevents the silent-overwrite failure that the Drive lesson warns about.
Build a small file upload-and-sync service that stores files as content-addressed chunks in an object store (real S3/MinIO or a local blob directory), keeps metadata in a separate database, syncs edits by transferring only changed chunks, deduplicates identical chunks, and resolves conflicting edits via a version chain — then measure the bandwidth and storage wins your design produces.
- A working service where an upload stores chunks in the object store and a metadata row in the DB, with NO file bytes ever held in a DB column or buffered whole in app memory — demonstrate this with a multi-hundred-MB file.
- A delta-sync demonstration: editing one chunk of a large file uploads only ~one chunk's worth of bytes, with a logged before/after byte count showing the order-of-magnitude saving vs full re-upload.
- A dedup demonstration: the same content stored twice occupies one physical chunk (shown via the blob store's object count and the reference count), and deleting one referencing version does not delete the still-referenced chunk.
- A conflict demonstration: two edits from the same parent version both survive as conflicted copies, with the version chain (parent pointers) shown — a last-writer-wins overwrite must NOT occur.
- A short write-up: the metadata-vs-blob split you chose and why, the measured delta-sync and dedup wins to one significant figure, and one paragraph on what would change to reach S3-like durability (erasure coding across failure domains) at real scale.
- Replace fixed-size chunking with content-defined chunking (a rolling hash boundary) and demonstrate that inserting bytes at the START of a file now re-syncs only the affected chunk instead of every subsequent chunk — quantify the difference.
- Add a push-style change notification: instead of clients polling for changes, have the server notify a connected client (WebSocket/long-poll) when a file changes, and have the client then pull only the metadata diff and missing chunks.
- Add an eventually-consistent counter (e.g. download count) implemented by logging events and aggregating asynchronously, and contrast its throughput with a synchronous per-event UPDATE under a load test.
- Simulate erasure coding: split a chunk into k data + m parity fragments, store them in separate 'nodes' (directories), delete up to m fragments, and reconstruct the chunk from the survivors — measuring the storage overhead vs a 3-copy replication of the same chunk.
- 01What is the core structural split the project forces you to build, and why?
- 02How do you demonstrate delta sync, dedup, and conflict safety, and what would scale them to S3-like durability?
This project turns the media-storage unit into a thing you have built. You stand up an object store for bytes and a separate metadata database, then implement the spine shared by YouTube, Drive, and S3: upload bytes directly to the blob store (never through an app-memory buffer or a DB column), split files into content-addressed chunks, and commit a metadata version listing the chunk hashes — chunks first, metadata second. From that one mechanism you get delta sync (edit a chunk, upload only that chunk, and measure the order-of-magnitude bandwidth saving), deduplication (identical chunks stored once with a reference count), and integrity for free. You make the system safe with a version chain — each version records its parent, so two edits from the same base both survive as conflicted copies rather than a silent overwrite — and you add a multipart-style upload to make a large file’s transfer reliable. The deliverable is not just code but measurement: the delta-sync and dedup wins to one significant figure, and a paragraph on what reaching real S3-like durability would require (erasure coding across failure domains). Build this once and the unit’s designs stop being diagrams and become muscle memory.
Something unclear?
Ask a question about this lesson. Questions are anonymous and go straight to the author to make the lesson better.