Implement data deduplication in a storage system
Instruction: Describe how you would implement data deduplication in a storage system to reduce redundancy and save space.
Updated
Official answer
Decide the deduplication unit and trust boundary: whole object or chunks, within one tenant or across tenants. Fixed chunks are simple; content-defined boundaries may preserve matches after insertions, but cost more to compute. Benchmark the actual data rather than equating fixed chunks with structured data and variable chunks with everything else.
Create a manifest mapping each logical object/version to ordered chunk references. Hash a chunk to find candidate matches, then use a collision policy that preserves correctness, such as comparing bytes before reusing a candidate. A forced hash collision must not silently replace distinct content.
Coordinate chunk creation and manifest publication atomically or with a recoverable protocol. Readers must never observe a manifest referencing unavailable data. Concurrent identical uploads need safe create-if-absent behavior; failed uploads must not leave permanent orphaned state.
Deletion removes logical references. Reclaim chunks only after proving that no live object/version or in-progress operation still requires them; use correctly synchronized reference accounting or a safe mark-and-sweep process. Verify stored bytes and restore complete objects in tests. One corrupted shared chunk can affect many logical files.
Consider encryption, access controls and information leaks: revealing that another tenant already stores a sensitive object can disclose information even without returning its bytes. Limit deduplication scope when required. Measure net space savings including indexes/manifests, upload/read latency and recovery cost; deduplication does not automatically simplify backups.
Related Questions
-
hard
-
hard
-
hard
-
hard