Design Google Drive

Cloud file storage and sync inspired by Google Drive and Dropbox: metadata separated from content, chunked resumable uploads deduplicated by content hash, a change journal with per-device cursors for sync, background scanning, previews and search, and versioning. A teaching design.

Functional requirements

  • Users can upload files of any size from web, mobile, and desktop clients.
  • Large files are split into chunks and uploaded in parallel via a resumable protocol.
  • Users can download files from any device; downloads are accelerated by a CDN.
  • Files are organised into nested folder hierarchies with inherited permissions.
  • Users can share files or folders with others using role-based access (owner, editor, commenter, viewer) or via expiring shared links.
  • File changes are synchronised across all connected devices in near real time.
  • Every file version is retained; users can browse history and restore any prior version.
  • Users can search for files by name, type, and full-text content.
  • Post-upload processing — thumbnail generation, virus scanning, search indexing — runs asynchronously without blocking the upload response.
  • Deleted files are moved to Trash and can be recovered within a configurable retention window before permanent deletion.

Non-functional requirements

  • Durability: file bytes must be stored with 99.999999999% (11-nines) durability using multi-AZ replication in object storage.
  • Availability: the service must achieve 99.99% uptime; no single component failure should make files inaccessible.
  • Scalability: the upload and download paths must independently scale to serve 1 billion+ files and millions of concurrent users.
  • Performance: file listing and metadata reads must complete in under 100 ms (p99) for cache-warm requests; CDN-served downloads must complete in under 200 ms (p99) globally.
  • Latency: ACL permission checks must add no more than 5 ms to any file operation, served from an in-memory cache.
  • Resumability: interrupted uploads must be resumable from the last successful chunk for up to 24 hours without restarting.
  • Consistency: metadata operations (rename, share, delete) must be strongly consistent; search index and thumbnail delivery may be eventually consistent within 30 seconds.
  • Security: all data must be encrypted in transit (TLS 1.2+) and at rest (AES-256); access tokens must be short-lived and rotated; all file accesses must be authorised against ACLs.
  • Isolation: virus-scanning workers must execute in isolated sandboxes; a compromised file must not affect other users' data.
  • Geo-distribution: files must be downloadable from edge nodes closest to the user; cross-region replication must tolerate a full regional failure with no data loss.
  • Observability: all upload, download, share, and delete events must be logged with user ID, timestamp, and outcome for audit and compliance.

How the design evolves

Stage 1: Single File Server

See why storing files on a server's disk can't scale or survive failures.

What was missing: Nothing yet.

Why that's risky: Files live on one machine's disk, every download streams through the server, and a large upload that drops restarts from zero.

What gets added: One server that saves files to its own disk and keeps their names and folders in a database.

Trade-offs: Simple, but storage, bandwidth and metadata all share one machine.

Stage 2: Metadata and Content Split, Downloads from a CDN

Keep file bytes in object storage, metadata in a database, and serve downloads from the edge.

What was missing: Bytes and metadata lived together on one server.

Why that's risky: Uploads are single requests: a dropped connection on a 2 GB file starts over, and identical files are stored many times.

What gets added: Object storage for file content, a sharded metadata database for names, folders, owners and permissions, a file service that hands out short-lived signed URLs, and a CDN that serves downloads through them.

Trade-offs: Signed URLs expire in minutes, so a shared download link must be refreshed by the file service.

Stage 3: Chunked, Resumable, Deduplicated Uploads

Make large uploads survive dropped connections and never store the same bytes twice.

What was missing: Uploads were all-or-nothing, and duplicates were stored repeatedly.

Why that's risky: Other devices don't learn about changes unless they re-list everything.

What gets added: An upload service that takes files in 8 MB chunks named by their SHA-256 hash, keeps an upload session so a dropped upload resumes, and lets the client skip chunks that already exist; plus a metadata cache for hot listings and permission checks.

Trade-offs: Content-addressed chunks make deduplication free but mean deleting a file can't delete chunks other files still use; garbage collection handles that later.

Stage 4: Sync: Change Journal and Notifications

Keep every device up to date without polling.

What was missing: Devices had to re-list folders to find changes.

Why that's risky: Uploaded files aren't scanned for malware, have no previews, and can't be searched by content.

What gets added: A change journal per user and shared folder with a cursor per device, a durable file event log written with each change (outbox pattern), and a sync service that holds a connection to each device and sends a small 'something changed' signal so the device pulls only changes after its cursor.

Trade-offs: Devices pull changes after a signal instead of receiving them pushed, which keeps the notification tiny and the journal the single source of order.

Stage 5: Scanning, Previews and Search

Process every upload in the background and make files findable.

What was missing: No malware scanning, previews or content search.

Why that's risky: Old versions and trashed files are kept forever, and nothing limits abusive clients.

What gets added: Workers on the file event log that scan uploads in a sandbox, build thumbnails and previews, and index names and contents into a per-user search index served by a search service.

Trade-offs: Until a scan finishes, only the owner can open a new file.

Stage 6: Versions, Trash, Protection and Monitoring

Restore old versions, clean up storage, and protect and watch the service.

What was missing: No version history, no cleanup, no per-user limits, no monitoring.

Why that's risky: Remaining risk is regional: metadata and chunks are replicated to a second region for disaster recovery.

What gets added: A versioning service that restores old versions by pointing at their chunks, a trash and retention worker that deletes expired files and unreferenced chunks, an API gateway with per-user limits, and monitoring of upload success, sync lag and scan backlog.

Trade-offs: Keeping versions costs storage; retention policies cap it.

Frequently asked questions

How do you handle large file uploads reliably?

Split files into chunks (e.g. 5–10 MB each) and upload them in parallel or sequentially. Each chunk is written to blob storage independently. A resumable upload session tracks which chunks have been received so a failed upload can resume from the last successful chunk rather than starting over.

How do you prevent two users from overwriting the same file simultaneously?

Use optimistic concurrency — tag each file version with an ETag or version number. On write, the client sends the version it last saw; the server rejects the write if the current version doesn't match, forcing the client to fetch the latest and re-apply its changes. For collaborative editing, operational transformation or CRDTs handle fine-grained conflict resolution.

How do you sync file changes across multiple devices in real time?

After every write, publish a change event to a notification service (e.g. via Server-Sent Events or WebSocket). Each connected device listens for events matching its user ID and re-fetches the changed metadata on receiving one. Delta sync — sending only the changed bytes — reduces bandwidth compared to re-downloading the full file.

How would you implement file deduplication to save storage?

Compute a content hash (e.g. SHA-256) of every chunk before storing it. Before writing a chunk to blob storage, check if an identical hash already exists. If it does, store only a pointer to the existing chunk. This is content-addressable storage — the same bytes are stored once regardless of how many users have uploaded identical files.

How do you model and enforce file sharing permissions?

Store permissions as an Access Control List (ACL) in the metadata database — each entry maps a (file_id, user_id/group_id) pair to a role (owner, editor, commenter, viewer). Cache hot ACLs in Redis. On every file operation, check the calling user's role. Link-based sharing generates a signed URL or a token that encodes the permission level and expiry.

When would you shard the metadata database?

Shard when the primary metadata DB can no longer handle write throughput or when the dataset no longer fits on a single node. Shard by user_id so all of a user's files live on the same shard — this keeps folder-listing queries local and avoids cross-shard joins. Add routing logic in the application layer to map user_id to the correct shard.

How do you ensure file durability and protect against data loss?

Object storage like S3 or GCS stores at least 3 copies of every object across different availability zones by default. Durability is typically 11 nines (99.999999999%). For extra protection, enable cross-region replication so a regional outage doesn't make data unavailable. Version history means deleted or overwritten files can be recovered within a retention window.

How do you make file search fast across billions of files?

After a file is uploaded, a worker indexes its name, MIME type, owner, and extracted text (for documents) into a dedicated search index like Elasticsearch. Queries run against the index rather than the metadata database. The index is updated asynchronously so it doesn't block uploads. Shard the index by user_id or org_id to keep queries isolated.

PRISM
System Design Interview
Round 1 of 4 · Architecture Design · 60:00 remaining
PRISM logo PRISM logo
Problems
AI Interview
Interview Challenges
Build & Stress Test NEW
System Architectures
Design & Fix NEW
Interactive Roadmap
System Design Guides Interview Prep Guide
Problems
Today's mission
Notifications
    Theme
    Pricing Community NEW Send feedback Report a problem NEW
    Sign in
    Theme
    Community NEW Send feedback Report a problem NEW
    All problems
    Phase
    Build & Stress Test
    Phase 01: Thinking in Systems
    Upcoming

    Components

    User
    CDN
    Load Balancer
    Server
    Cache
    Database
    Blob Storage
    Search Index
    Queue
    Worker
    Rate Limiter
    Service
    API Gateway
    Reverse Proxy
    WebSocket Server
    Third-party API

    Inspector

    Notes
    Use clear names so your design intent is easy to understand.
    Good
    Name by business meaning
    "Order API", "Restaurant Service"
    Avoid
    Generic names = zero signal
    "Server 1", "API", "Queue"
    A short description for each component makes feedback much better.
    100%
    Start by identifying:
    • Users & entry points
    • APIs & services
    • Databases & storage
    • Traffic flow & scale

    Round 1 of 4 Architecture Design

    Run a simulation to see results.

    Time Remaining
    60:00
    System Design Interview

    What are the core functional requirements?
    What are the key non-functional constraints?

    Questions

    Start Evaluation to unlock questions.

    EVALUATE MODE

    Test yourself like it's the real thing.

    A structured 4-module evaluation that mirrors how top companies assess system design candidates.

    Architecture Design
    Draw your system on the canvas. Define components, connections, and data flow.
    FR & NFR Requirements
    Answer functional and non-functional requirement questions about your design.
    MCQ Round
    Multiple choice questions testing your depth on the chosen system.
    Tradeoff Analysis
    Justify your design decisions and defend your architectural tradeoffs.
    AI Report Generated
    Choose a Problem
    No problem selected
    • 30 min
    • 45 min
    • 60 min
    Round 2 of 4
    MCQ Round
    Answer multiple-choice questions based on your design.

    Exit Interview?

    You're in the middle of an interview session. Leaving now will end your current attempt.

    Your progress will be saved.

    Open a saved design

    Select a design to load into the canvas.

    My Evaluations

    Your past evaluation sessions

    Here’s a simple request flow that follows the expected layer order.

    External User
    →
    Edge CDN → API Gateway → Load Balancer
    →
    Compute App Servers / Services
    →
    DataAccess Cache
    →
    Storage Database / Search Index
    →
    Async Queue → Worker

    Tip: keep arrows moving forward through layers (Edge → Compute → Storage). Avoid sending storage back to compute.

    Evaluation Instructions

    Read the rules carefully before starting. The test auto-submits on refresh.

    Before you start

    • Build your architecture on the canvas. The timer starts when you click Start Evaluation.
    • Don't forget to answer Functional Requirement and Non Functional Requirements.
    • When satisfied with your design, click Next to lock it and view the questions.
    • Please answer final step questions to complete the evaluation.

    Dos

    • Do read each question carefully before answering.
    • Do include required components to maximize component coverage.
    • Do save a copy of your design if you want to keep it before submission.

    Don'ts

    • Don't refresh or close the tab during an active evaluation — this will auto-submit your answers.
    • Don't switch app modes or open another tab while the evaluation is running.
    • Don't attempt to edit the design after clicking Next; the workspace will be locked.

    All the best!!

    Confirm

    Input

    Notice

    Evaluation Report
    Report a problem

    Evaluation Complete

    Generating Your Report

    Hang tight — our AI is evaluating your design…

    Did you know?

    Loading…

    Share feedback

    Tell us what worked well and what we can improve.

    Let's personalize this

    Answer a couple of quick questions so we can tailor your journey and missions.

    Your welcome gift: of Full PRISM Access

    Your Pro access starts as soon as you press Start my journey.

    SYSTEM BRIEF

    System Constraints

    What the system must do — every item is a user-facing behaviour your architecture must support.

      ↑ Engineering Constraints

      These are the failure modes you must design against — latency SLAs, durability targets, traffic ceilings.

        ⇆ Architecture Constraints

        Core Concepts to Master

        Your Journey
        PHASE – –
        0 / 0 0%
        0
        Mock Interview Checklist

        Pick a topic to start

        Explore concept overviews, real-system examples, key tradeoffs, and interview talking points for each roadmap section.

        Phase Mastered

        You've conquered this phase. These are the skills you now own:

          +500 XP

          Company Interview Paths

          Progress Summary