Design a distributed file storage service like Dropbox or Google Drive
HardConceptMedia & Commerce
Answer
Requirements: users upload and download files of any size, changes sync automatically across devices, files are versioned and shareable, and data is never lost.
- Chunking: the client splits each file into blocks of a few megabytes and hashes them; only new or changed blocks are uploaded, which enables resumable uploads and deduplication.
- Block storage: blocks are kept in durable object storage, addressed by their hash.
- Metadata service: a strongly consistent database records files, folders, versions and the ordered list of block hashes for each version.
- Sync: a notification service informs other devices of changes over long polling or WebSockets; they fetch the new metadata and any missing blocks. Concurrent edits produce a conflicted copy.
- Trade-off: smaller blocks improve deduplication and delta sync but increase metadata size and request count.
More in Media & Commerce
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Design a video streaming service like YouTube | Concept | Hard | Read the answer to Design a video streaming service like YouTube | |||
| 2 | Design a ride-hailing service like Uber | Concept | Hard | Read the answer to Design a ride-hailing service like Uber | |||
| 3 | Design an e-commerce checkout system | Concept | Hard | Read the answer to Design an e-commerce checkout system | |||
| 4 | Design a distributed file storage service like Dropbox or Google Drive | Concept | Hard | Read the answer to Design a distributed file storage service like Dropbox or Google Drive |