Architecting a Durable, Always-On Object Store at Scale
System DesignModel answerLast updated
Design a horizontally scalable object storage service with buckets, keys, and huge blobs, covering metadata, placement, durability, consistency, large uploads, security and operations.
Build a cloud object store
Imagine you are asked to design a cloud-scale object storage service in the spirit of a public cloud's bucket-and-key offering. Customers group data into named containers (buckets) and save binary objects of any size under string keys. The service must hold billions of objects, stay reachable through hardware and facility failures, and almost never lose data.
What the service should offer
- Create and remove buckets.
- Upload an object, download it (whole or a byte range), fetch its metadata only, and delete it.
- List the objects in a bucket, optionally filtered by key prefix, with pagination.
- Handle very large objects efficiently.
Qualities to address
- Scale to billions of objects and very high request rates.
- High availability, including surviving the loss of an entire data center zone.
- Extremely high durability.
- Reasonable latency for small objects and high throughput for large ones.
Topics your answer should cover
- Requirements and a rough sizing estimate.
- The external API.
- Data model for buckets, objects, metadata, and where the bytes physically live.
- Overall architecture: request tier, metadata layer, storage nodes, background workers.
- How data and metadata are partitioned and how requests are routed.
- Durability and failure handling: replication or erasure coding, failure domains, repair.
- Consistency guarantees and the step-by-step flow of a write and a read.
- Large-object handling: multipart upload, resumability, range reads.
- Security: authentication, authorization, encryption in transit and at rest.
- Monitoring, key metrics, and capacity planning.
Walk through an upload and a download end to end, point out the major trade-offs, and justify each decision.
Hints
Hint 1
Begin with numbers: object count times average size gives logical capacity, erasure-coding overhead gives raw capacity, and per-object metadata size tells you whether metadata fits on one machine.
Hint 2
Keep metadata (small, hot, transactional) separate from data (large, immutable, written once) so each can be scaled, stored, and tuned on its own terms.
Hint 3
Think in failure domains (disk, host, rack, zone). Spread replicas or erasure-coded fragments so that losing a whole zone is survivable, and reason about how fast repair is, since that drives durability.
Hint 4
Make the metadata commit the single point where an object becomes visible; that gives you read-after-write consistency for a key and clean handling of failed uploads (orphan data is garbage-collected).
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Requirements and sizing
Functional: bucket create/delete/list; object PUT, GET (with ranges), HEAD, DELETE; prefix LIST with pagination; multipart upload. Versioning and lifecycle rules are optional extras.
Non-functional:
- Durability: around 11 nines. Losing data is worse than a brief outage.
- Availability: about 99.99%, tolerating loss of a full zone.
- Consistency: read-after-write for a single key; LIST may be slightly stale unless the metadata store makes it strong cheaply.
- Latency: p99 time-to-first-byte of roughly 100 ms for small objects; large objects are throughput-bound.
Back-of-envelope: 100B objects at 1 MB average is about 100 PB logical. With 1.5x erasure-coding overhead, about 150 PB raw, or about 7,500 20 TB disks before headroom and IOPS needs. Metadata at about 1 KB per object is about 100 TB, so it must be sharded. Peak load might be around 1M GET/s and 100K PUT/s, with a skewed size distribution (many small, few multi-GB).
2. API
PUT /{bucket}create bucketPUT /{bucket}/{key}upload (single shot, capped at a few GB)GET /{bucket}/{key}with an optionalRangeheaderHEAD,DELETEon the same pathGET /{bucket}?prefix=&start_after=&limit=list- Multipart: initiate (returns an upload id), upload part N (returns a part ETag), complete (send the ordered part list), abort
Requests are signed (HMAC-style). Clients may send a content hash so the server can verify integrity end to end; responses return an ETag.
3. Data model
- Bucket record: name, owner, region, policy/ACL, versioning flag, encryption config. Small, strongly consistent, heavily cached.
- Object metadata: key
(bucket_id, object_key, version_id); fields for size, ETag, content type, user metadata, timestamps, storage class, encryption key reference, delete marker, and an ordered chunk list (chunk id, offset, length), with chunks of about 64 MB. - Placement map (data plane): chunk id to the fragments' nodes, disks and extents.
The central decision is splitting metadata from data. Metadata is small, hot and needs transactions; data is big, immutable and append-friendly.
4. Architecture
- DNS and load balancers direct clients to a nearby region and spread load.
- Stateless front-end tier: authentication, authorization, throttling, request parsing, streaming bytes. Scales horizontally.
- Metadata service: range-sharded key-value store, each shard a Raft/Paxos group of 3 to 5 replicas across zones.
- Placement service: knows nodes, free space and failure domains; picks targets for new chunks.
- Storage nodes: write fragments into large append-only extent files, keep a local index, and checksum every block.
- Background workers: scrubber (checksum verification), repair, garbage collector (deleted objects, abandoned multipart uploads), rebalancer, lifecycle/tiering, metering.
5. Partitioning and routing
- Metadata: range-partition on
(bucket_id, key)so prefix listings are sequential scans. Shards split automatically when large or hot. Front-ends cache the shard map and refresh on a stale-hit error. Monotonic key prefixes (timestamps) create hotspots; mitigate with automatic hot-range splitting and by advising customers to randomize prefixes. - Data: the placement service chooses locations based on free capacity, load and failure-domain rules, and the result is recorded in metadata. Compared with consistent hashing this costs an extra lookup, but permits rebalancing, draining nodes and domain-aware placement.
6. Durability and fault tolerance
- Hot or small objects: 3x replication across 3 zones. Cheap reads and simple repair, at 3x storage cost.
- Bulk or cold data: Reed-Solomon, for example RS(8,4): 8 data + 4 parity fragments, 1.5x overhead, at most 4 fragments per zone, so a full zone loss plus extra disk failures is survivable. A common pattern is writing replicated first and converting to erasure coding when data cools.
- Integrity: per-block checksums verified on read and by periodic scrubbing, plus an object-level hash.
- Repair: nodes send heartbeats; declare a node dead after roughly 10 to 15 minutes to avoid rebuild storms on reboots. Rebuild the most endangered chunks first, spread across many disks for speed, and throttle so foreground traffic is not starved. Durability depends heavily on mean time to repair.
- Metadata: quorum replication across zones plus backups and point-in-time snapshots.
7. Consistency and flows
PUT:
- Front-end authenticates and authorizes, then asks placement for targets.
- It streams data in, erasure-codes inline, and writes fragments to nodes in parallel, each with checksums.
- After a sufficient write quorum is durable (all fragments, or e.g. 11 of 12 with the rest repaired later), it commits the metadata row through the shard's Raft leader. This commit is the visibility point.
- Return success and the ETag. Data written by a failed request is orphaned and cleaned by GC.
GET:
- Authenticate, then read the metadata row (leader or a linearizable read) to get the chunk list.
- Look up placement and fetch the needed fragments; for a range request, only the chunks overlapping the range. With erasure coding, read the data fragments, and fall back to parity reconstruction if some are slow or missing (hedged reads help tail latency).
- Verify checksums, stream to the client.
Because the metadata commit is atomic and reads go through the same replicated shard, you get read-after-write for a key. Concurrent writers to one key resolve as last-writer-wins by commit order (or via conditional writes with ETag preconditions). DELETE writes a tombstone; GC reclaims space later.
8. Large objects
Multipart upload: initiate, upload parts in parallel (each independently retriable, checksummed), then complete by sending the part list; the server stitches the parts' chunk lists into one manifest and commits metadata atomically, with no data copy. Abandoned uploads expire via lifecycle GC. Range reads translate byte offsets to chunk indexes, enabling parallel and resumable downloads.
9. Security
- Signed requests for authentication; IAM-style policies, bucket policies and ACLs for authorization, evaluated at the front-end with cached policy.
- TLS in transit.
- At rest: envelope encryption, with a per-object data key wrapped by a key-management service master key; optionally customer-managed keys.
- Audit logs, and presigned URLs with expiry for delegated access.
10. Operations
- Metrics: request rate, error rate and p50/p99/p999 latency per operation; per-shard hotness; under-replicated chunk count; repair backlog and time; scrubber error rates; disk, node and zone utilization.
- Alerts: durability-risk signals (chunks at minimum fragments), availability SLO burn, capacity runway.
- Capacity planning: forecast growth, keep headroom (about 20 to 30 percent) and plan for a zone-loss rebuild that temporarily needs extra space and bandwidth. Track metadata growth separately from data growth.
Trade-offs and common mistakes
- Replication vs erasure coding: latency and simplicity vs cost.
- Strong vs eventual listing: strong is simpler for customers but costs more in metadata.
- Quorum writes trade a little durability margin for tail latency.
- Mistakes: putting data and metadata in one store, ignoring failure domains, skipping checksums and scrubbing, repairing too eagerly or too slowly, forgetting orphan cleanup, and hashing keys in a way that destroys prefix listing.