Nâng CaoSystem Design iconSystem Design

Thiết kế hệ thống File Storage như Google Drive hoặc Dropbox. Các thành phần chính? (Design a file storage system like Google Drive or Dropbox. Key components?)

Requirements: upload/download/sync files, share với others, version history, ~1B users, ~10 exabytes storage.

  • Chunking: chia file thành chunks (4-8MB), mỗi chunk được hash (SHA-256) để detect duplicates (deduplication) và support delta sync (chỉ upload chunks thay đổi).
  • Upload flow: Client chunker → tính hash của mỗi chunk → gửi chunk hashes lên server → server trả lại chunks nào cần upload → client upload missing chunks lên Blob Storage (S3) → server ghi metadata vào DB.
  • Metadata DB: lưu file tree structure, ownership, permissions, version history – dùng RDBMS (MySQL) cho ACID và complex queries.
  • Blob Storage: S3-compatible object storage cho raw file chunks.
  • Deduplication: nếu hai users upload cùng file, chỉ lưu một bản vật lý, tham chiếu từ nhiều users – tiết kiệm storage đáng kể.
  • Sync service: khi file thay đổi trên device A → upload delta chunks → notify other devices qua WebSocket/long polling → devices download changed chunks.
  • Conflict resolution: last-write-wins hoặc tạo conflict copy như Dropbox.

Bandwidth optimization: client-side deduplication và delta sync giảm upload data tới 90%. Permission model: owner, editor, viewer; sharing links với expiry. CDN cho download popular files. File metadata search dùng Elasticsearch.

Xem toàn bộ System Design cùng filter theo level & chủ đề con.

Mở danh sách System Design