Compile Ready
All system design questions
System Design/Common Interview Questions

Google Drive

Design a collaborative cloud-storage platform with sharing, versioning, and real-time collaboration.

Advanced 60m interview 22m read High frequency Popularity 85
Google Microsoft Amazon

Problem Statement

Design Google Drive, a cloud storage and collaboration platform where users can create folders, upload files, edit documents together, share resources with fine-grained permissions, search content, and keep desktop or mobile clients synchronized across devices.

At interview scale, assume billions of files and folders, hundreds of millions of active users, massive metadata QPS, petabytes of blob content, and a mix of workloads: small metadata reads, large uploads and downloads, real-time collaborative document edits, search indexing, permission checks, and change feeds for sync clients.

The core challenge is not simply storing bytes. A strong design separates metadata from blob storage, treats permissions and inherited ACLs as first-class data, supports versioned and deduplicated content, keeps collaboration convergent, and guarantees that sharing or revocation decisions are enforced before content is served.

Business use case

Google Drive lets individuals and organizations store files safely, collaborate without emailing attachments, recover previous versions, and access content from any device. It becomes the source of truth for documents, spreadsheets, presentations, PDFs, images, and shared team folders.

For businesses, Drive also provides governance: enterprise permissions, audit logs, retention, data loss prevention, eDiscovery, quota controls, and secure sharing with customers or partners. The product succeeds when storage, collaboration, sync, search, and access control feel like one reliable system.

Functional Requirements

  • Create, rename, move, delete, restore, and list files and folders in a hierarchical namespace.

  • Upload and download file content with chunking, resumability, deduplication, checksums, and version history.

  • Create and edit collaborative documents with real-time multi-user convergence.

  • Share files and folders with users, groups, domains, and links using roles such as viewer, commenter, editor, and owner.

  • Apply inherited folder permissions while allowing safe overrides and revocation.

  • Expose a change feed so desktop, mobile, and offline clients can sync deltas from a cursor.

  • Search by file name, metadata, owner, permissions, and extracted file content.

  • Track storage quota, retention, trash lifecycle, and per-user or per-organization usage.

Non-Functional Requirements

Latency

Metadata reads such as listing a folder or opening a file should complete in under 100ms p99 within a region. Permission checks must be in the same latency budget. Collaborative edit operations should be acknowledged in under 150ms p99 so typing feels live. Large downloads can be bandwidth-bound, but time to first byte should be low through CDN and signed origin URLs.

Availability

Users expect existing files to remain readable even when search, notifications, or collaboration features degrade. Target at least 99.99 percent availability for metadata and content access, and isolate optional systems so indexing lag or notification failure does not block uploads, downloads, or permission enforcement.

Metadata scalability

The system must handle billions of nodes and very high QPS for folder listing, permission checks, recent files, sync cursors, and search lookups. Metadata services should shard by stable identifiers rather than full path strings, and should avoid expensive recursive operations on hot folders.

Durability and versioning

Uploaded content and metadata changes must be durable before the client sees success. File content should use checksums, multi-zone replication, immutable blob chunks, version manifests, and background repair. Metadata should retain enough history for restore, audit, conflict resolution, and legal retention.

Permission correctness

The design should prefer temporary denial over accidental over-sharing. New grants should become visible quickly, but revocations and ownership changes need bounded propagation and cache invalidation so a stale ACL cache cannot serve private content after access was removed.

Collaboration convergence

Multiple users editing the same document concurrently must converge to the same state. The collaboration layer needs ordering, conflict resolution, session recovery, idempotent operation replay, and periodic snapshots so clients can rejoin without downloading an unbounded operation log.

Cost and quota efficiency

Storage cost dominates at petabyte scale. Deduplicate chunks, compress where useful, tier cold versions, avoid indexing unnecessary binary data, and maintain quota ledgers that are accurate enough for enforcement without requiring synchronous global accounting on every upload byte.

Capacity Estimation

Assumptions

Assume 1B registered users, 300M daily active users, 20B file and folder metadata nodes, 1B metadata mutations per day, and 30B metadata reads per day from web, mobile, desktop sync, and collaboration surfaces.

Assume 50M new file versions per day with an average logical size of 8 MB. Deduplication and compression reduce physical storage by about 35 percent. Assume 1B file downloads per day with an average served size of 3 MB, most of which should come from CDN or regional blob serving. Peak traffic is 10x average for metadata and 8x average for content transfer.

Metadata nodes

20B files and folders

Includes folders, binary files, native docs, shortcuts, and trash entries

Metadata storage

40 TB raw

20B nodes times 2 KB average metadata record before indexes and replicas

Replicated metadata

180 to 240 TB

Indexes, ACL materialization, versions, change history, and 3x to 4x replication

Average metadata read QPS

347,000 reads per second

30B reads per day divided by 86,400 seconds

Peak metadata read QPS

3.5M reads per second

10x peak for login storms, workday starts, and sync catch-up

Average metadata write QPS

11,600 writes per second

1B metadata mutations per day divided by 86,400 seconds

New logical content

400 TB per day

50M new versions times 8 MB average logical size

New physical content

260 TB per day

35 percent savings from chunk deduplication, compression, and sparse versions

Download bandwidth

35 GB per second average

1B downloads per day times 3 MB divided by 86,400 seconds

Collaboration operations

200,000 ops per second peak

1M peak concurrent editors averaging one operation every five seconds

Search index

100 to 150 TB

Metadata, permissions, extracted text, thumbnails, and inverted indexes

Calculations

  • Metadata records: 20B nodes times 2 KB is 40 TB raw. With secondary indexes, ACL-derived fields, change history, and 3x to 4x replication, plan for roughly 180 to 240 TB.
  • Metadata reads: 30B reads per day divided by 86,400 seconds is about 347,000 reads per second on average. A 10x peak means about 3.5M reads per second.
  • Metadata writes: 1B mutations per day divided by 86,400 seconds is about 11,600 writes per second on average. A 10x peak means about 116,000 writes per second.
  • Content ingest: 50M new versions per day times 8 MB is 400M MB per day, or about 400 TB logical. With 35 percent savings, physical ingest is about 260 TB per day before replication.
  • Download bandwidth: 1B downloads per day times 3 MB is 3B MB per day, about 3 PB per day. Dividing by 86,400 seconds gives about 35 GB per second average. An 8x peak is about 280 GB per second, mostly handled by CDN and regional blob stores.
  • Collaboration: 1M concurrent editors at one operation every five seconds produces 200,000 operations per second. The operations are small, but ordering, fanout, and persistence dominate.
  • Change feed: if each metadata mutation and committed collaboration batch emits one event, the feed must absorb more than 1B events per day before retries and backfills.

API Design

POST/api/v1/nodes

Creates a folder, shortcut, native document, or upload placeholder under a parent folder. Binary file content is uploaded separately so metadata and blob transfer can scale independently.

Request


{
  "parentId": "folder_123",
  "name": "Quarterly Plan",
  "nodeType": "document",
  "mimeType": "application/vnd.google-apps.document",
  "clientMutationId": "cm_9f21"
}

Response


{
  "nodeId": "file_456",
  "parentId": "folder_123",
  "name": "Quarterly Plan",
  "nodeType": "document",
  "version": 1,
  "createdAt": "2026-07-26T07:10:00Z"
}
  • 201Node created
  • 400Invalid name, parent, or node type
  • 401Authentication required
  • 403Caller cannot create under this parent
  • 409Duplicate client mutation or conflicting name policy
  • 429Rate limit or quota guard exceeded
PUT/api/v1/files/{fileId}/content

Commits a new binary file version after the client uploads chunks to signed upload URLs. The commit validates checksums, quota, parent permissions, and idempotency.

Request


{
  "uploadSessionId": "up_789",
  "chunkManifestId": "manifest_abc",
  "logicalSizeBytes": 8388608,
  "sha256": "a4f1c2...",
  "clientMutationId": "cm_9f22"
}

Response


{
  "fileId": "file_456",
  "versionId": "ver_002",
  "logicalSizeBytes": 8388608,
  "deduplicatedBytes": 3145728,
  "quotaBytesCharged": 5242880,
  "committedAt": "2026-07-26T07:12:00Z"
}
  • 200Version committed
  • 400Invalid manifest or checksum mismatch
  • 403Caller cannot edit this file
  • 404File or upload session not found
  • 409Stale base version or duplicate mutation
  • 413File exceeds product limit
  • 429Quota exceeded or throttled
GET/api/v1/files/{fileId}/content

Returns metadata plus a short-lived signed download URL, or streams the content through the service for small files. The service must authorize the caller before issuing any content URL.

Response


{
  "fileId": "file_456",
  "versionId": "ver_002",
  "downloadUrl": "https://download.example.com/signed/ver_002",
  "expiresAt": "2026-07-26T07:22:00Z",
  "etag": "v2-acl17"
}
  • 200Authorized download information returned
  • 304Client cache is still valid
  • 401Authentication required for private file
  • 403Caller lacks view permission
  • 404File not found or hidden by permissions
  • 410Version deleted or expired by retention policy
POST/api/v1/nodes/{nodeId}/permissions

Shares a file or folder with a principal or link policy. Folder grants can be inherited by descendants, but the write must be represented as an ACL version so readers can detect stale authorization data.

Request


{
  "principalType": "user",
  "principalId": "user_999",
  "role": "commenter",
  "inheritance": "propagate",
  "message": "Please review"
}

Response


{
  "permissionId": "perm_321",
  "nodeId": "file_456",
  "role": "commenter",
  "aclVersion": 18,
  "createdAt": "2026-07-26T07:13:00Z"
}
  • 201Permission grant created
  • 400Invalid role, principal, or inheritance mode
  • 403Caller cannot share this resource
  • 404Node not found
  • 409Conflicting ownership or policy rule
GET/api/v1/changes

Returns ordered changes visible to the caller after a cursor. Sync clients use this endpoint to update local state, recover from offline periods, and learn about permission or trash changes.

Response


{
  "nextCursor": "cursor_2049",
  "hasMore": true,
  "changes": [
    {
      "sequence": 2048,
      "nodeId": "file_456",
      "changeType": "content_updated",
      "removed": false,
      "modifiedAt": "2026-07-26T07:12:00Z"
    }
  ]
}
  • 200Changes returned
  • 400Cursor is malformed or too old
  • 401Authentication required
  • 410Cursor expired and full resync is required
  • 429Sync client is polling too aggressively
PATCH/api/v1/docs/{fileId}/operations

Submits a batch of collaborative document operations based on a known revision. The collaboration service transforms or merges concurrent operations and returns the committed revision.

Request


{
  "baseRevision": 1042,
  "clientId": "client_a",
  "operations": [
    { "type": "insert_text", "position": 188, "text": "Launch plan" }
  ]
}

Response


{
  "fileId": "file_456",
  "committedRevision": 1043,
  "transformedOperations": [
    { "type": "insert_text", "position": 192, "text": "Launch plan" }
  ]
}
  • 200Operations committed
  • 400Invalid operation batch
  • 403Caller cannot edit the document
  • 409Base revision is too old for incremental transform
  • 429Document or client is rate limited

Separate metadata APIs from content transfer. Metadata endpoints return stable IDs, versions, ACL versions, cursors, and signed content URLs. Blob uploads and downloads should flow through resumable sessions, CDN, and object storage rather than through one monolithic API service. Collaboration APIs are revision-based so clients can retry safely and recover after disconnects.

Database Design

The metadata model is a graph with a dominant tree shape: each node has a stable ID, usually one parent, a name, a type, ownership, timestamps, and a current version pointer. Stable IDs avoid rewriting descendants when folders move or names change.

Permissions are separate from file versions because sharing changes should not rewrite content. Blob data is immutable and addressed by chunk or content hash, while file versions reference manifests that point to those chunks.

drive_nodes
node_iduuidPrimary key for files, folders, documents, shortcuts, and trash entries
owner_iduuidOwning user, shared drive, or organization
parent_iduuid nullableFolder parent; null for roots and shared drive roots
namevarchar(1024)Display name within the parent namespace
node_typevarchar(32)Folder, binary_file, native_doc, shortcut, or shared_drive
mime_typevarchar(255)Content type or native document type
current_version_iduuid nullableHead file version for binary content or native document snapshot
acl_versionbigintMonotonic value used to invalidate stale permission decisions
created_attimestampCreation time
modified_attimestampMetadata or content modification time
trashed_attimestamp nullableSoft-delete marker before retention cleanup
permissions
permission_iduuidPrimary key for an explicit grant
resource_node_iduuidFile or folder where the grant is attached
principal_typevarchar(32)User, group, domain, organization, public_link, or service_account
principal_idvarchar(255)Principal identifier or link token hash
rolevarchar(32)Viewer, commenter, editor, organizer, or owner
inheritance_modevarchar(32)This node only, inherit to descendants, blocked, or owner-only
expires_attimestamp nullableOptional time-bound access grant
created_byuuidActor that granted access
revoked_attimestamp nullableSoft revoke for audit and cache invalidation
file_versions
version_iduuidImmutable version identifier
node_iduuidFile or native document node
base_version_iduuid nullablePrevious version for diff and conflict handling
chunk_manifest_iduuidManifest of ordered blob chunks
content_hashchar(64)Hash used for deduplication and integrity
logical_size_bytesbigintSize charged before dedup policy adjustments
physical_size_bytesbigintNew bytes actually stored after deduplication
created_byuuidActor that created the version
created_attimestampVersion commit time
retention_classvarchar(32)Active, historical, legal_hold, archived, or expired
storage_accounts
account_iduuidUser, shared drive, or organization quota bucket
quota_bytesbigintAllowed logical or billed storage
used_bytesbigintEventually consistent charged usage
reserved_bytesbigintBytes reserved by in-flight uploads
planvarchar(64)Free, paid, enterprise, education, or internal
updated_attimestampLast quota ledger update
change_log
shard_idvarchar(64)Change feed partition, often derived from owner or drive ID
sequence_numberbigintMonotonic sequence within the shard
actor_iduuidUser or service that caused the change
node_iduuidAffected file or folder
change_typevarchar(64)Created, moved, renamed, permission_changed, content_updated, trashed, or deleted
acl_versionbigintPermission version visible with this change
payload_pointervarchar(255)Pointer to larger event payload if needed
created_attimestampEvent time used for sync and auditing

Indexes

  • drive_nodes.node_id is the primary lookup key for open, update, move, and permission checks.
  • drive_nodes.parent_id, name supports folder listing and uniqueness rules inside one folder.
  • drive_nodes.owner_id, modified_at supports recent files and owner-scoped sync.
  • permissions.resource_node_id supports loading explicit grants for a file or folder.
  • permissions.principal_id, role supports shared-with-me and enterprise access reviews.
  • file_versions.node_id, created_at supports version history and restore.
  • change_log.shard_id, sequence_number supports cursor-based sync with ordered pagination.
  • Search should use a separate inverted index because metadata stores are not optimized for full-text ranking.

Relationships

Each node belongs to an owner or shared drive and usually has one parent. Folder inheritance is logical: descendants do not need a copied ACL row for every inherited grant. Permission evaluation combines explicit grants, inherited ancestors, organization policy, and link policy. File versions reference immutable blob manifests, and change_log events reference nodes so clients can sync without scanning the metadata tables.

NoSQL alternatives

A production design can use a globally distributed SQL database such as Spanner or FoundationDB for metadata transactions, because moves, shares, and version commits need conditional updates and consistent indexes. Blob chunks belong in object storage such as Colossus, S3, Azure Blob Storage, or a custom distributed file system with replication and erasure coding.

The change feed can live in Bigtable, Kafka, Pulsar, or a log-structured store partitioned by owner or shared drive. The search index should be external, such as Elasticsearch, OpenSearch, Solr, or a custom inverted-index service. ACL-derived fields may be denormalized into the search index, but every content access must still be authorized against a fresh enough permission decision.

High-Level Architecture

Drag to pan · Ctrl/⌘ + scroll to zoom

Metadata, permission checks, content blobs, collaboration sessions, search, and sync events are separate planes. The critical safety invariant is that every content URL or edit operation is authorized before access is granted.

The write path starts in the gateway, which authenticates the caller and routes metadata, content, sharing, and collaboration requests to specialized services. The Metadata Service owns file and folder state, the Permission Service owns ACL evaluation, and the Blob Service owns resumable upload, deduplication, version manifests, and download URLs.

The Blob Store is optimized for large immutable chunks and high-throughput transfer, while the Metadata Store is optimized for small strongly consistent records. The Change Feed decouples sync clients, notifications, audit, search indexing, and offline recovery from the user-facing transaction. Search is a derived system, not the source of truth for access control.

Real-time documents use the Collaboration Service because their workload is different from binary uploads. It maintains active sessions, orders or merges operations, creates snapshots, and emits committed changes back to metadata and sync systems.

Request Flow

  1. 1

    Client authenticates and opens a folder

    The client sends a folder listing request through the API Gateway. The gateway verifies identity, applies rate limits, and forwards the request to the Metadata Service with caller identity, device state, and requested pagination.

  2. 2

    Metadata service evaluates permissions

    The Metadata Service loads the target folder metadata and asks the Permission Service whether the caller can view it. The Permission Service combines explicit ACLs, inherited parent grants, group membership, link policy, domain policy, and the folder ACL version.

  3. 3

    Folder listing is returned

    The Metadata Service reads children by parent_id, filters entries the caller cannot see, and returns stable IDs, names, types, modified times, version IDs, and ACL versions. Large folders use pagination and may require specialized indexes or materialized listings.

  4. 4

    Client uploads file chunks

    For binary content, the client creates an upload session and uploads chunks to signed URLs. The Blob Service validates chunk checksums, checks deduplication indexes, stores missing chunks, and tracks uploaded ranges so interrupted clients can resume.

  5. 5

    Version commit updates metadata and quota

    After all chunks arrive, the Blob Service commits a version manifest and asks the Metadata Service to atomically update the file head, modified time, version history, and quota reservation. The commit is idempotent by client mutation ID.

  6. 6

    Change feed and search are updated asynchronously

    The metadata transaction emits a change event. Sync clients later read it from the cursor endpoint, notification workers may alert collaborators, and indexers extract metadata or content text into the search index. Upload success does not wait for search indexing.

  7. 7

    Sharing change bumps ACL version

    When a user shares or revokes access, the Permission Service records the grant or revoke and increments the relevant ACL version. Caches and derived indexes use that version to detect stale permission decisions.

  8. 8

    Collaborative edits converge

    For a native document, clients send edit operations to the Collaboration Service. It orders, transforms, or merges concurrent operations, persists the operation log, periodically writes snapshots, and emits committed document changes to the Change Feed.

Core Components

Metadata Service

Owns file and folder hierarchy, node metadata, moves, trash, and version pointers.

This service handles create, rename, move, list, restore, and version-head updates. It should use stable node IDs instead of path-based keys, apply idempotency for client retries, and keep transactions small enough to avoid recursive folder rewrites.

Permission Service

Evaluates sharing policies and inherited ACLs before metadata, content, or collaboration access.

The service resolves direct grants, folder inheritance, group membership, link settings, organization policy, ownership, and role hierarchy. It maintains ACL versions so stale caches can be rejected, and it treats revocation as a high-priority invalidation path.

Blob Service

Manages resumable uploads, downloads, chunk manifests, deduplication, checksums, and immutable versions.

The Blob Service issues signed upload and download URLs, validates chunk integrity, stores missing chunks, commits version manifests, and enforces file-size limits. It should not decide authorization alone; it receives an authorization decision from metadata and permissions.

Collaboration Service

Keeps live document editing sessions convergent and low-latency.

This service stores operation logs, assigns revisions, performs Operational Transform or CRDT merging, broadcasts operations to active collaborators, and writes periodic snapshots. It isolates high-frequency edit operations from the general metadata path.

Change Feed

Provides ordered deltas for sync clients, notifications, audit, and derived indexes.

The feed is partitioned by owner, shared drive, or another stable scope. It must provide durable cursors, replay, compaction rules, and a clear full-resync path when a client cursor is too old.

Search Index

Enables name, metadata, and content search with permission-aware filtering.

Indexers consume change events, extract text from supported file formats, tokenize metadata, and attach ACL-derived visibility fields. Search results must still respect current permissions, especially after revocation or group membership changes.

Metadata Store

Durable transactional source of truth for nodes, ACLs, version pointers, quota ledgers, and sync cursors.

Use a distributed transactional store for strong conditional updates such as move, share, version commit, and quota reservation. Shard by stable IDs and owner scopes, and keep secondary indexes aligned with the most common access patterns.

Blob Store

Stores immutable chunks, manifests, thumbnails, and cold versions at petabyte scale.

The blob layer should use replication or erasure coding, checksums, background scrubbing, lifecycle tiering, and regional placement. It is optimized for high-throughput transfer and durability rather than folder listing or ACL evaluation.

Deep Dive

Hierarchy metadata and folder moves

A naive design stores full paths such as /team/plans/q3.docx in every descendant. Moving a large folder would require rewriting all child paths and invalidating huge parts of the index. The better design uses stable node IDs with parent_id references. A move updates only the moved folder parent pointer and name, then emits one change for the moved subtree root.

Folder listing is still hard because large shared folders can have millions of children and many concurrent viewers. Use parent_id plus sorted pagination indexes, cap page sizes, and treat extremely large folders as a special scale case with materialized child lists or partitioned listing tables.

Name uniqueness is a product decision. If names must be unique within a folder, enforce uniqueness with a conditional write on parent_id and normalized name. If duplicates are allowed, folder listing can be simpler, but the UI and sync clients need stable IDs to distinguish same-name files.

Permissions, sharing graph, and inherited ACLs

Permissions are the distinguishing part of Drive compared with a simple object store. A file may be visible because of direct user access, a group grant, a domain grant, a public link, ownership, shared drive membership, or inherited folder ACLs. The Permission Service should evaluate these sources in a predictable order and return the effective role.

Do not copy every folder ACL to every descendant for normal inheritance. That makes sharing a folder with a million files too expensive and makes revocation dangerous. Instead, store explicit grants at the folder and evaluate ancestors or maintain compact materialized ACL summaries with an acl_version. Caches are allowed, but the version must let services reject stale decisions.

Revocation is more sensitive than granting. If a user removes access, cached signed URLs, search results, collaboration sessions, and sync clients must stop exposing content within a bounded window. Short-lived download URLs, ACL-versioned cache keys, and high-priority invalidation events are essential.

Blob storage, deduplication, versioning, and quota

Binary file content should be stored as immutable chunks and manifests. Chunking enables resumable upload, parallel download, deduplication, and partial retry. Content-addressed chunks let identical bytes be stored once, while manifests define each file version as an ordered list of chunks.

Deduplication has tradeoffs. Global dedup saves the most storage but can leak information if an attacker can infer whether a chunk already exists. Safer designs deduplicate within a tenant or use server-side checks that do not reveal cross-tenant existence. Compression and thumbnail extraction should run asynchronously.

Quota should be charged at version commit time using a reservation model. Reserve expected bytes when upload starts, adjust charged bytes after deduplication, and release reservations on abort. The quota ledger can be eventually consistent for display, but enforcement needs enough atomicity to stop unlimited overage.

Real-time collaboration with Operational Transform or CRDTs

Native documents are not just files with frequent saves. Multiple users edit paragraphs, tables, comments, and formatting at the same time. The service receives operations based on different revisions and must produce a convergent document state for every participant.

Operational Transform keeps a server-ordered log and transforms incoming operations against concurrent committed operations. It gives centralized control and mature semantics, but transform functions are complex for rich document structures. CRDTs allow more decentralized merging and offline edits, but can add metadata overhead and need careful compaction.

In an interview, choose a collaboration model and explain why. For a Google Drive style product, a server-mediated OT or server-coordinated CRDT design is practical: active sessions are routed to a collaboration shard, operations are persisted before acknowledgement, snapshots bound replay cost, and offline clients reconcile local edits through operation replay or conflict copies.

Change feed, offline sync, and conflict handling

Sync clients cannot scan all files repeatedly. They need a durable change feed scoped to the user or shared drive. Each event has an ordered sequence, affected node, change type, tombstone marker, and enough metadata for the client to update local state or request details.

Clients go offline, miss events, and reconnect with old cursors. The service should retain change history for a defined window, then return a cursor expired response that forces a full or scoped resync. Events should be idempotent because clients may receive duplicates after retries.

Conflicts happen when two offline clients edit or move the same binary file. Metadata conflicts can use last-writer-wins only for safe fields, but content conflicts often require creating a conflict copy or a separate version for user resolution. Native documents can merge operations through the collaboration engine.

Search indexing with permission filtering

Search uses derived data: file names, owners, MIME types, timestamps, OCR text, extracted document text, labels, comments, and thumbnails. Indexers consume the change feed and update an inverted index asynchronously, so search freshness is eventually consistent.

Permission filtering must be designed carefully. One option stores ACL-derived visibility tokens in the index and filters candidate documents by the caller's tokens. That is fast but must react to revocation and group changes. Another option performs post-filter authorization against the Permission Service, which is safer but can increase latency and reduce recall if many candidates are filtered.

A balanced design uses visibility tokens for broad filtering, ACL versions for freshness, and final authorization for sensitive downloads. Search can lag after upload, but it must not reveal a private file after access is removed.

Scaling

Prototype: single region and simple storage

Start with one API service, a relational database for nodes and permissions, object storage for file content, and basic upload or download APIs. Implement stable file IDs, folder listing, owner-only access, simple sharing, and version history before adding global sync.

Growth: split metadata, blob, and search paths

Introduce dedicated Metadata, Blob, Permission, and Search services. Add resumable uploads, signed download URLs, CDN for content, background indexers, and a change feed for desktop and mobile clients. Cache metadata reads but preserve ACL correctness with versioned decisions.

Large scale: distributed metadata and partitioned feeds

Move metadata to a distributed transactional store, partition change feeds by owner or shared drive, add quota reservations, deduplicate chunks, and isolate collaboration sessions. Large folders, hot shared documents, and enterprise groups require specialized sharding and cache invalidation.

Global scale: regional content and multi-region metadata

Replicate blob content across regions or place it near active users. Route metadata to a home region or use a globally consistent database for critical metadata. Keep signed URLs short-lived, route downloads through CDN, and ensure revocations propagate across regions quickly.

Enterprise scale: governance, compliance, and reliability isolation

Add audit pipelines, DLP scanning, eDiscovery, legal holds, tenant-level keys, admin policy engines, and capacity isolation for large organizations. Search, sync, collaboration, and notifications should degrade independently so core file access remains available.

Bottlenecks & Optimizations

Hot metadata partitions from large shared folders

Partition child listings for huge folders, use stable node IDs, paginate aggressively, cache folder pages, and avoid updating every child when the folder moves or is shared. For team drives, shard by shared drive and subfolder ranges rather than one root key.

Permission evaluation and revocation fanout

Use compact ACL inheritance, group membership caches with short TTLs, ACL versions, and high-priority invalidation. Do not materialize every inherited grant to every descendant unless a background job can safely rebuild summaries.

Blob ingest bandwidth and checksum CPU

Upload directly to regional blob endpoints with signed URLs, validate chunks in parallel, use content-defined chunking where helpful, apply backpressure per tenant, and separate upload workers from metadata services.

Real-time collaboration hot documents

Route each active document to a collaboration shard, use sticky sessions or document ownership leases, batch broadcasts, snapshot frequently, and split very large sessions into substreams for comments, presence, and document operations.

Change feed lag during sync storms

Partition feeds by owner or shared drive, let clients use exponential backoff, prioritize recent visible changes, compact old events, and provide a full-resync path when cursors expire. Keep search and notification consumers from starving sync consumers.

Search index stale or over-broad after permission changes

Emit ACL change events with high priority, include ACL versions in index documents, filter by visibility tokens, and perform final authorization for sensitive results. If in doubt, hide stale results until reindexed.

Failure Handling

Metadata store regional failure

Fail traffic to a healthy region with replicated metadata if available. If strong writes are unavailable, allow read-only access to recently replicated metadata and content while pausing risky operations such as share, move, or delete. Prefer denying edits over causing divergent metadata.

Blob store or CDN outage

Serve from another replica or origin region, reduce thumbnail and preview quality, and keep metadata operations available. Upload sessions should remain resumable, and clients should retry missing chunks rather than restarting whole files.

Permission cache is stale after revocation

Use short-lived signed URLs, ACL-versioned cache keys, deny-list invalidation for revoked resources, and a final permission check before issuing new download URLs. If the permission system is uncertain, return 403 instead of serving content.

Collaboration server crashes during an edit session

Persist operations before acknowledgement, route clients to a replacement session owner, replay from the last snapshot, and deduplicate client operation IDs. Presence can be lost, but committed document operations must not be lost or applied twice.

Change feed consumer lag or corruption

Keep the primary metadata transaction independent of downstream consumers. Consumers should checkpoint offsets, replay from durable logs, and rebuild derived state from metadata snapshots when needed. Sync clients should receive cursor-expired responses rather than silent gaps.

Quota ledger mismatch

Use upload reservations to bound overuse, reconcile charged bytes from version manifests, and run periodic ledger repair. If the ledger is temporarily unavailable, allow small trusted uploads within a risk budget and reject large uploads until quota can be verified.

Security

Authorization on every access

Every metadata read, download URL issuance, upload commit, share change, and collaboration operation must be authorized. Never rely only on hidden URLs or client-side filtering. Use least-privilege service credentials and audit privileged access.

Safe link sharing

Public or domain links should use unguessable tokens, optional expiration, download restrictions, and admin policy checks. Link token hashes should be stored instead of raw tokens, and revocation should invalidate active links quickly.

Encryption and key management

Encrypt data in transit and at rest. Large enterprises may need customer-managed keys, per-tenant key isolation, key rotation, and crypto-shredding for deleted or offboarded tenants.

Malware, abuse, and DLP scanning

Uploaded files and shared links can distribute malware or leak sensitive data. Scan risky files asynchronously, block known-bad content, integrate data loss prevention policies, and support quarantine without deleting evidence needed for audit.

Privacy-aware search and previews

Search snippets, thumbnails, OCR output, and previews can leak content. Index and render them only for authorized users, redact sensitive fields where policy requires it, and remove derived artifacts when access is revoked or content is deleted.

Auditability and compliance

Record share, view, download, admin, retention, and ownership events with tamper-resistant logs. Enterprise customers need legal hold, retention windows, eDiscovery exports, and policy evidence during incident investigations.

Tradeoffs

Pros

  • +Separating metadata from blob storage lets each scale for its own workload.
  • +Stable node IDs make folder moves cheap and avoid path rewrites across descendants.
  • +Versioned immutable blobs improve durability, restore, deduplication, and conflict handling.
  • +ACL versions and short-lived signed URLs reduce the risk of stale permission decisions.
  • +A change feed decouples sync, search, notifications, and audit from user-facing writes.

Cons

  • Permission inheritance and group membership make authorization more complex than simple object ACLs.
  • Search and sync are eventually consistent, so the product must explain freshness and cursor behavior.
  • Global metadata consistency is expensive, especially for moves, ownership changes, and revocation.
  • Deduplication saves storage but introduces privacy, accounting, and operational complexity.
  • Real-time collaboration requires a specialized subsystem rather than ordinary file version uploads.

Alternatives

Alternative one is an object-store-first design: put every file in object storage and store minimal metadata in a database. It is simple for personal backup but weak for folder hierarchy, sharing inheritance, search, and collaboration.

Alternative two is a fully path-based file system namespace. It is intuitive but expensive for moves and rename operations across large subtrees. Stable IDs with parent pointers scale better.

Alternative three is a centralized collaboration document store for all content. It works for native docs but is inefficient for large binary files, videos, archives, and offline desktop sync.

When not to use this design

Do not design Google Drive when the requirement is only archival object storage, a CDN-backed static file host, or a database for structured records. Drive is appropriate when users need human-facing hierarchy, sharing, collaboration, sync, versioning, search, and governance over files.

Follow-up Questions

How do you avoid rewriting millions of descendants when a folder moves?

Use stable node IDs and parent_id pointers instead of storing full paths as primary identity. Moving a folder updates one parent pointer and emits a change event. Folder listings compute the visible path from parent links or cached breadcrumbs, and search indexes update derived paths asynchronously.

How do you enforce inherited folder permissions efficiently?

Store explicit grants at the resource where they are created and evaluate inheritance through ancestor summaries or cached effective ACLs. Use acl_version values to detect stale permission decisions. Avoid copying every inherited permission to every descendant on the synchronous share path.

How do you revoke access quickly when a file was already shared?

Increment the ACL version, invalidate permission caches, expire or deny existing signed URLs, remove link tokens, notify collaboration sessions, and prioritize search index updates. If a service cannot verify current permissions, it should deny access rather than serve stale content.

How do offline clients resolve conflicts?

Clients replay local mutations with client mutation IDs when they reconnect. Metadata operations can use conditional versions and safe last-writer policies for simple fields. Binary content conflicts create separate versions or conflict copies. Native docs merge through the collaboration operation log.

Why not store file bytes in the metadata database?

Metadata records need low-latency transactions and indexes, while file bytes need high-throughput streaming, replication, erasure coding, and lifecycle tiering. Combining them makes both paths harder to scale and more expensive.

How does search respect permissions at scale?

Index documents with visibility tokens or ACL summaries, filter candidate results by the caller's identity and groups, and use ACL versions to detect stale results. For sensitive content, perform a final permission check before returning previews or download URLs.

How do you choose between Operational Transform and CRDTs for docs?

Operational Transform is natural for a server-ordered collaboration service and mature for text editing, but rich document transforms are complex. CRDTs handle offline and peer-style merging better but add metadata overhead. A strong answer chooses one, explains convergence, and includes snapshots and operation compaction.

Company Variations

Google

Google interviewers are likely to probe global metadata scale, collaboration correctness, permission revocation, search freshness, and the separation of Drive storage from Docs collaboration. Be ready to explain how ACL versions, change feeds, and operation logs interact.

Microsoft

Microsoft may frame this as OneDrive or SharePoint: enterprise identity, groups, tenant policy, compliance, retention, audit, and Office-style collaboration. Emphasize Azure-style blob storage, Entra ID group membership, legal hold, and admin controls.

Amazon

Amazon interviewers often push on S3-like durability, DynamoDB or Aurora partitioning, cost, operational alarms, and failure isolation. Discuss direct-to-object-store transfer, quota enforcement, conditional writes, and reducing blast radius across services.

Meta

Meta may focus on high-QPS metadata serving, media blobs, privacy, graph-based sharing, and realtime collaboration or comments. Expect follow-ups on cache invalidation, privacy reviews, and fanout from popular shared folders.

Interview Tips

Start by stating that Google Drive is a metadata and permissions problem wrapped around petabyte blob storage, not just a file upload API. Draw the metadata path, permission path, blob path, collaboration path, and change-feed path separately. Then explain the hardest invariants: never serve content without authorization, do not rewrite huge subtrees for moves or shares, keep versions durable, and make offline clients converge.

What interviewers expect

  • Separate metadata service, blob storage, permission service, collaboration service, change feed, and search index.
  • Use stable file IDs, parent pointers, version manifests, and immutable chunks.
  • Explain inherited ACL evaluation and why revocation is safety-critical.
  • Cover sync clients with durable cursors, tombstones, idempotent events, and full-resync fallback.
  • Discuss Operational Transform or CRDTs for collaborative documents.
  • Tie capacity numbers to metadata reads, writes, content ingest, download bandwidth, and collaboration ops.

Common mistakes

  • !Designing only an object store and forgetting hierarchy, sharing inheritance, sync, and collaboration.
  • !Serving downloads from signed URLs without rechecking permissions or bounding URL lifetime.
  • !Copying folder ACLs to every descendant synchronously on share or revoke.
  • !Using full paths as primary keys and making folder moves rewrite entire subtrees.
  • !Treating search index results as authoritative for access control.

Red flags

  • ×No concrete capacity math for metadata QPS, blob storage, and download bandwidth.
  • ×No answer for offline sync cursors, cursor expiry, and conflict copies.
  • ×No versioning or checksum strategy for uploaded content.
  • ×No distinction between binary file uploads and real-time native document editing.
  • ×No plan for permission revocation and stale cache invalidation.

Revision Notes

  • Store file and folder identity as stable node IDs with parent_id links. Do not use full paths as primary keys.
  • Split the system into Metadata Service, Permission Service, Blob Service, Collaboration Service, Change Feed, Search Index, Metadata Store, and Blob Store.
  • Metadata scale is huge: 20B nodes at 2 KB each is about 40 TB raw, and 30B metadata reads per day is about 347,000 read QPS average.
  • Content scale is larger in bytes: 50M new versions per day at 8 MB each is about 400 TB logical ingest per day before deduplication.
  • Blob content should be immutable chunks plus manifests, with checksums, resumable upload, deduplication, version history, and lifecycle tiering.
  • Permissions need explicit grants, inheritance, groups, links, domain policy, ACL versions, short-lived signed URLs, and high-priority revocation invalidation.
  • Native documents need a collaboration layer using Operational Transform or CRDTs, persisted operation logs, active session routing, and snapshots.
  • Change feeds power sync clients, notifications, audit, and search indexing. Cursors must be durable, idempotent, and able to expire into full resync.
  • Search is derived and eventually consistent. It can filter by visibility tokens, but sensitive access still needs permission checks.
  • Quota enforcement should reserve bytes during upload and reconcile charged usage after deduplication and version commit.

Flashcards

Quiz

0/6 answered

  1. 1.What is the best primary identity for files and folders in a Drive-like system?

  2. 2.Why should file content be stored separately from metadata?

  3. 3.Which mechanism most directly helps detect stale authorization decisions?

  4. 4.What should a sync client do when its change cursor is too old?

  5. 5.Which subsystem handles concurrent edits to a native document?

  6. 6.Why is copying inherited ACLs to every descendant during a share problematic?

Cheat Sheet

Goal: design cloud storage with hierarchy, sharing, versioning, collaboration, search, sync, quota, and secure content delivery.

Core split: Metadata Service for nodes and versions, Permission Service for ACLs and inheritance, Blob Service for chunks and manifests, Collaboration Service for native docs, Change Feed for sync and derived systems, Search Index for discovery.

Scale assumptions: 20B metadata nodes, 30B metadata reads per day, 1B metadata mutations per day, 50M new file versions per day, 400 TB logical ingest per day, and about 35 GB per second average download bandwidth.

Metadata model: stable node_id, parent_id, owner_id, node_type, current_version_id, acl_version, timestamps, and soft-delete state. Avoid path-based primary keys.

Blob model: resumable upload sessions, immutable chunks, content hashes, manifests, checksums, deduplication, version history, lifecycle tiering, and short-lived signed download URLs.

Permissions: direct grants, inherited folder ACLs, groups, domains, public links, owner policy, ACL versions, cache invalidation, and final authorization before content access.

Collaboration: route active documents to collaboration shards, persist operations, use Operational Transform or CRDTs, broadcast to collaborators, and snapshot to bound replay cost.

Sync: emit ordered change events with cursors, tombstones, idempotency, cursor expiry, and full-resync fallback. Offline binary conflicts produce conflict copies; native docs merge operations.

Search: index metadata and extracted content asynchronously, filter by visibility tokens, track ACL versions, and never treat the index as the source of truth for downloads.

Reliability: isolate search, notifications, and previews from core file access. Prefer denying uncertain access over accidentally over-sharing.

References