Design S3-Like Object Storage: Placement Groups, Erasure Coding & Compaction
How Cloud Object Storage Achieves 99.999999999% (11 Nines) Durability
Bucket / ObjectKey -> Immutable Blob, scaling cleanly to exabytes across commodity disks.S3-Like Object Storage Architecture
1. Separating Data Routing From Metadata
Client ──(HTTP PUT/GET)──► API Gateway (IAM Auth)
│
┌──────────────────┴──────────────────┐
▼ ▼
[Metadata Service (SQL/KV)] [Data Store + Placement Service]
(bucket, object_name -> uuid, (Maps uuid -> Data Node Group,
version_id, object_mapping) streams directly to NVMe/HDD pools)
- Metadata DB: Stores small records mapping
(bucket_id, object_key, version_id)→object_uuid+ byte locations. Never caches massive blobs inside SQL. - Data Store Nodes: Append immutable object bytes directly into large pre-allocated 2 GB Data Files (
write-once, append-only!) rather than creating millions of tiny OS filesystem inodes.
2. Solving Small File Fragmentation: Read-Only Compaction
- Incoming objects append sequentially to an active Read-Write Data File (saving exact
(file_id, offset, size)in local RocksDB). - Once a file hits
2 GB, it seals Read-Only and a fresh active file opens. - Background Compaction: Periodically merges sealed files containing deleted objects, copying surviving bytes into fresh compact files and updating object offsets atomically!
3. Replication vs. Erasure Coding (Storage Cost vs. Durability)
3× full replicas everywhere (like HDFS) wastes 200% extra hardware capacity.| Strategy | Storage Overhead | Fault Tolerance | Best For |
|---|---|---|---|
| 3-Way Replication | 3.0× (200% overhead) | Survives 2 node losses | Hot, small, latency-sensitive chunks |
| Reed-Solomon Erasure Coding (8+4) | 1.5× (50% overhead!) | Survives any 4 drive/rack failures | S3 Standard / Archive exabyte scale |
(k=8, m=4), an object splits into 8 data chunks + 4 parity chunks spread across 12 distinct failure domains (racks/nodes). You lose 3–4 entire servers simultaneously and reconstruct every byte mathematically while cutting storage bills in half vs. 3× replication!4. Multipart Upload & S3 Versioning
- Multipart Upload: Files $> 100\text{ MB}$ split into independent parts uploaded in parallel (
upload_id + part_number), committed atomically viaCompleteMultipartUpload—making retries after flaky network drops trivial. - Versioning & Soft Deletes: Deletions simply append a
DeleteMarkerversion row rather than erasing physical blocks immediately, enabling instant undelete and safe async garbage collection.