Folders are a lie — the flat keyspace and its index
Keys are flat opaque strings with no real directories, so the index is a giant sorted map from key to location that shards by key range — which means all keys sharing a prefix land on one partition that has a throughput ceiling.
Surviving disk death means the bytes live somewhere other than one disk — so something has to record where; that something is the index, the first plane we crack open.
Scene 03
Folders are a lie — the flat keyspace and its index
- Watch
- Try it
- Predict
- Capture
Each object is addressed by a key — and a key is one flat string; the slashes in "logs/2026/06/03/app.log" are just bytes, not folders. The map on the right sorts those strings and shards them by range. Try the console-folder toggle: it splits the keys on '/' into a tree, but there is no tree underneath.
Highlighted lines are the ones running in the diagram right now.
def resolve(key):# key is ONE opaque string; '/' is just a byte.# No tree walk — binary search the sorted map.part = partitionForKey(key)entry = part.lookup(key) # key -> location + metadatareturn entry.locationdef partitionForKey(key):# partitions are contiguous lexicographic key ranges,# so keys sharing a prefix land on ONE partition.return bisect(partitionBoundaries, key)
# limits are PER partition, not per bucketPUT_CEILING = 3500 # req/sGET_CEILING = 5500 # req/sdef serveRequest(req):rate = self.observedRate(req.kind)ceiling = (PUT_CEILING if req.kind == PUTelse GET_CEILING)if rate > ceiling:return Http503('SlowDown')return serve(req)
# background loop on the index planedef maybeSplit(part):if part.sustainedRate > part.ceiling:mid = part.medianKey()# split the range at mid -> two partitions,# each owning half the keys. Takes minutes,# so a sudden hot prefix throttles first.lo, hi = part.splitAt(mid)partitionBoundaries.insert(mid)
Where this sits in Build an S3-style distributed object store
Scene 03 of 12, in the Name & shape act — The flat keyspace, its index, and immutable objects.. Keys are flat strings; the index maps key→location and shards by range, with a per-prefix throughput ceiling.
Up next. The index records where an object's current bytes are — but what exactly is it pointing at, and what happens to the old bytes when you overwrite a key?
All 12 scenes in Build an S3-style distributed object store · Every curriculum