To bound blast radius during partial cluster failures, fixed-size chunking suffers from the boundary-shift problem; CDC with a rolling hash + SHA-256 deduplication achieves true O(delta) uploads across multi-gigabyte files.
TL;DR30-second simplified summary▾
Clients slice files using Gear/Rabin rolling hashes, compute SHA-256 digests, and query the Block Service for missing hashes. Only unstored chunks are compressed, encrypted with tenant DEKs, and uploaded to S3.
The Fixed-Chunk Boundary-Shift Problem.
Why this matters: Observe why naive 4 MB fixed-size splitting fails on prepend or mid-file edits.
Fixed-size chunking slices a file at offsets 0, 4MB, 8MB, ....
If a user prepends a 1 KB header to a 100 MB VM image or video project, every downstream 4 MB boundary shifts by 1 KB.
Fixed-Size Boundary Shift
1.Offset Fragility: Byte offsets shift globally on any insertion or deletion.
2.Zero Dedup: 10 bytes edited can trigger gigabytes of redundant transfer.
Fixed-offset chunking breaks deduplication whenever bytes are inserted or deleted.
Rolling Hash Mechanics (Rabin Fingerprint & FastCDC).
Why this matters: Compute content-dependent cut points in O(1) per byte using a sliding window.
Think of Rolling Hash Mechanics (Rabin Fingerprint & FastCDC) as the intuition layer for Content-Defined Chunking (CDC) & Cross-Device Delta Sync: Compute content-dependent cut points in O(1) per byte using a sliding window.
Instead of re-hashing a 48-byte window from scratch at each byte, a rolling hash updates the hash in O(1) arithmetic when the window slides by 1 byte (out_byte leaves, in_byte enters). Modern FastCDC uses a Gear hash lookup table to scan at >1 GB/sec on a single CPU core.
O(1) Sliding Rolling Hash
1.1+ GB/s Speed: Gear hashing avoids modular division, running near memory-copy speed.
2.Local Anchoring: Cut points depend only on the surrounding ~48 bytes.
A rolling hash finds content-anchored boundaries in a single linear O(N) pass.
- Problem
- How to implement Content-Defined Chunking (CDC) & Cross-Device Delta Sync without hitting unbounded tail latency, state divergence, or operational fragility.
- Naive Solution
- Use a single unpartitioned path with unbounded retries and synchronous global coordination.
- Why It Fails
- Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
- Alternatives
- Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
- Engineering Decision
- To bound blast radius during partial cluster failures, fixed-size chunking suffers from the boundary-shift problem; CDC with a rolling hash + SHA-256 deduplication achieves true O(delta) uploads across multi-gigabyte files.
- Trade-Offs
- Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
When Content-Defined Chunking (CDC) & Cross-Device Delta Sync experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?
Min/Max Chunk Clamping & Normalized Chunking.
Why this matters: Prevent pathological tiny (1-byte) or huge (100 MB) chunks by enforcing [min_size, max_size] bounds.
Think of Min/Max Chunk Clamping & Normalized Chunking as the intuition layer for Content-Defined Chunking (CDC) & Cross-Device Delta Sync: Prevent pathological tiny (1-byte) or huge (100 MB) chunks by enforcing [min_size, max_size] bounds.
A raw random bitmask follows a geometric distribution, occasionally producing 10-byte chunks (metadata explosion) or 50 MB chunks (poor dedup). Enforcing min_size (e.g., 2 MB) skips hash checks until min_size bytes are read, while max_size (e.g., 8 MB) forces a cut, keeping chunk counts and metadata predictable.
Bounded Chunk Size Distribution
1.Metadata Bound: min_size guarantees at most N / min_size chunk entries.
2.FastCDC Trick: Using a stricter mask before avg_size narrows variance.
Clamping chunk sizes between `min_size` and `max_size` bounds both metadata overhead and tail upload size.
SHA-256 Content-Addressable Storage & Delta Negotiation.
Why this matters: Check which chunk hashes already exist on the server before uploading any binary payload.
Think of SHA-256 Content-Addressable Storage & Delta Negotiation as the intuition layer for Content-Defined Chunking (CDC) & Cross-Device Delta Sync: Check which chunk hashes already exist on the server before uploading any binary payload.
After slicing a file into CDC chunks, the client computes each chunk's SHA-256 digest and sends the ordered hash list ([h1, h2', h3, h4]) to the Block Service. The server checks its chunk index and returns only missing hashes ([h2']), cutting upload traffic by >90% on incremental edits.
Hash-First Delta Negotiation
1.Content-Addressable: Chunks are stored at `blocks/{sha256}`—identical chunks across files share 1 copy.
2.Bandwidth Win: Editing 1 slide in a 500 MB deck uploads ~4 MB instead of 500 MB.
Negotiating SHA-256 manifests before uploading ensures only genuinely new chunks cross the wire.
Chunk Compression, Convergent vs. Per-Tenant Encryption.
Why this matters: Balance storage deduplication against zero-knowledge tenant encryption.
Think of Chunk Compression, Convergent vs. Per-Tenant Encryption as the intuition layer for Content-Defined Chunking (CDC) & Cross-Device Delta Sync: Balance storage deduplication against zero-knowledge tenant encryption.
Cross-user deduplication requires identical plaintext chunks to produce identical ciphertext (convergent encryption using HMAC(chunk_hash, chunk)), which can leak whether another user owns a known file. Enterprise systems therefore scope deduplication per tenant_id using per-tenant KMS keys and Zstd compression per chunk.
Per-Tenant Encryption & Zstd
1.Skip Incompressible: JPEG/MP4 chunks skip compression to save CPU.
2.Privacy Boundary: Per-tenant keys prevent cross-org hash-oracle side channels.
Per-tenant encryption and conditional compression protect privacy without sacrificing org-level dedup.
Reference Counting & Safe Orphan Chunk Garbage Collection.
Why this matters: Delete unreferenced S3 chunks safely without racing against concurrent uploads or file restores.
Because multiple file versions share chunk h1, deleting a file cannot immediately delete h1 from S3.
A naive ref_count == 0 delete races with an in-flight upload that just skipped h1 during negotiation.
Two-Phase Grace-Period GC
1.TOCTOU Fix: Grace window + row lock prevents deleting a chunk while a client is referencing it.
2.Version History: 30-day file undo keeps chunk references alive until snapshot expiry.
Grace-period mark-and-sweep GC prevents race conditions when reclaiming unreferenced blocks.
Version Vectors & Cross-Device Conflict Forks.
Why this matters: Detect concurrent offline edits across devices and preserve both copies without data loss.
If Laptop A and Laptop B both edit budget.xlsx while offline, neither should silently overwrite the other.
Each file carries a monotonic revision_id and parent pointer.
Optimistic Revision & Conflict Fork
1.Zero Silent Loss: Conflicting offline edits are preserved as separate files.
2.Fast Sync: The forked file still reuses all unchanged CDC chunks in S3.
Optimistic revision checks detect offline edit races and create safe conflict copies.
Practice: Make the trade-off yourself.
Why does Content-Defined Chunking (CDC) outperform fixed 4 MB chunking when 50 bytes are inserted at the start of a 2 GB file?