AlgoViz

Inside a blob store

hard 30 min

How a blob store is built: a gateway, a metadata service that knows where each piece is, data nodes that hold pieces, and background jobs that repair, move and delete.

See it run

Follow a blob from upload to deletion, lose some pieces, and get them back.

Operations

The life of a blob

Upload, store, replicate, serve and clean up.

Step 1 of 8

Upload request

Our systemClientCDNAPI gatewayMetadataemptyRepairNode 1emptyNode 2emptyNode 3empty

Upload: request

The client asks the gateway, with size and type.

Step 1: Upload request

url = api.sign(user, key)          # uploadfor part in split(file):    put(url[part], part)pieces = encode(chunk)             # storeplace(pieces, zones)metadata.commit(key, manifest)replicate_later(manifest)          # replicatecdn.serve(key)                     # servecollect_garbage()                  # clean up
Protects
Whole system
Price
Background jobs
One server
one disk failure from loss

Name the phase you are in: upload, store, replicate, serve, collect.

In the real world

The same inside a blob store doing real jobs. Pick one and step through it.

Detection, degraded reads, repair.

Step 1 of 4

Heartbeats stop

Our systemClientCDNAPI gatewayMetadatadragon: c0 c1 c2RepairNode 1c0, parityNode 2c1, parityNode 3c2, parity

Wait for the grace time

Node 2 is silent.

Step 1: Heartbeats stop

Common mistakes

The bugs interviewers watch for, with the fix beside each.

  • Name before bytes

    critical

    A reader follows the manifest to a chunk that is not there.

    Wrong
    metadata.commit(key, ids)store(chunks)
    Right
    ids = store(chunks)metadata.commit(key, ids)
  • All pieces in one rack

    critical

    Nine pieces behind one power supply are one failure.

    Wrong
    place(pieces, same_rack)
    Right
    place(pieces, spread="zone", max_per_zone=3)
  • Deleting orphans at once

    critical

    A running upload looks like an orphan until its commit.

    Wrong
    if not in_manifest(c): delete(c)
    Right
    if orphan(c) and age(c) > GRACE:    quarantine(c)
  • Using the ETag as the id

    major

    Two blobs with equal bytes can share an ETag. A copy would overwrite a record.

    Wrong
    blob_id = response["ETag"]
    Right
    blob_id = new_unique_id()

Interview tips

  • Memory trick: PUMP

    • Presigned URL request
    • Upload parts in parallel
    • Monitor with tags
    • Post the complete request
  • Memory trick: DICE

    • Deduplication
    • Intelligent tiering
    • Compression
    • Erasure coding
  • Draw it like this

    • Gateway, then names above and bytes below.
    • Background jobs dashed.
    • Zones as boxes.
  • Expect these questions

    • What if it crashes between the two writes?
    • What does a rebuild read?
    • Who deletes, and when?