KatInterview

Sizing and Securing a Deduplicating Document Vault

System DesignModel answer
MediumModel answerSystem Designcapacity-estimationdeduplicationencryption

Last updated

Design a long-term document storage service: estimate storage with replicas, add ingestion-time deduplication, and layer encryption, key management, authorization and versioning.

Scenario

Your team is building a document vault. Users upload files (PDFs, DOCX, images), fetch them later, and update them over time. Expected load:

  • 10,000 uploads per day
  • About 5 MB per file on average
  • Every document must be kept for at least 5 years
  • Traffic is uneven, with occasional bursts well above the average

What to cover

  1. Capacity estimate. How much raw storage is needed for one year of uploads? How much if the business also requires two additional copies of all data in geographically separate regions? State your assumptions, including how you read "two backups" and which unit convention you use.
  2. Deduplication at ingestion. Propose an architecture that detects identical files as they arrive. Describe the upload flow, the data model, and what the extra work does to upload performance.
  3. Security. Explain how stored files are encrypted at rest and how you make sure only authorized users can reach a given file. Which components handle key management and authorization checks?

Also address

  • How the design copes with traffic bursts.
  • The trade-offs of computing the content hash on the client versus on the server.
  • What happens when a user replaces or edits an existing document (versioning).

Give concrete numbers where you can, and call out the risks and trade-offs of your choices.

Hints

Hint 1

Start with the arithmetic: files per day times size per file, then scale to a year, then multiply by the number of copies. Say explicitly whether 'two backups' means 2 or 3 total copies.

Hint 2

Think content-addressable storage: use a cryptographic hash of the bytes as the blob key, keep logical documents as separate rows that point to blobs, and decide how concurrent uploads of the same new content are resolved.

Hint 3

Deduplication interacts with security. Consider what a client-supplied hash leaks (does a file exist?), whether the server must re-verify it, and how per-user encryption keys conflict with cross-user dedup. Scoping dedup to a tenant is one answer.