algomiBlogs
← All posts

Designing Photo Storage: From Small Files to a Large Photo Service

Algomi Research · Created 2026-09-16 · Updated 2026-10-15 · System Design

System Design Case Studies · Part 7 of 15
Designing a CDN: Put Popular Content Near Its ReadersDesigning a Job Scheduler: Remember the Work, Expect Retries
Page 1 of 1

400 wedding photos on a train

Sunita is on the overnight train home from her cousin's wedding. She uploads 400 photos to the family album on YaadeinPics as the Wi-Fi comes and goes. Some uploads retry three times. Next week she'll remove a relative from the album, and in five years one photo will be silently corrupted on a disk somewhere. (Sunita, YaadeinPics, Arvind and every number here are made up for teaching.)

Arvind designs YaadeinPics' storage. He starts with an old school problem. Imagine a school keeping a million photographs, each in its own envelope. Finding the right envelope could take more effort than looking at the picture. A catalogue that says "box 18, position 42" makes retrieval easy.

A photo service has two related jobs:

  1. Store the image bytes.
  2. Keep enough information to find and protect them.

Uploading a photo also creates thumbnails, records ownership, and eventually makes the photo visible to the people allowed to see it.

What happens Idea it forces
"Where do the bytes go, and where does 'who can see it' go?" Separate bytes from metadata
"Her phone retried an upload three times" Upload as an idempotent workflow
"Her aunt's phone needs small images" Deterministic variants built by a worker
"She removed a relative from the album" Private reads, signed links, revocation
"A disk flipped a bit in one photo" Durability, checksums, repair
"She deleted a photo; is it really gone?" Deletion as a tracked workflow
"Billions of tiny files are slowing the disks" Packing files, as in Haystack

In 30 seconds, as an architect would frame it: "I keep metadata (owner, album, visibility, workflow state) in a relational store and bytes in a blob store, joined by stable IDs. Clients upload straight to blob storage with a scoped, signed link. The service verifies the object, and a worker builds deterministic variants from an outbox work item, so retries never duplicate. Reads go through a CDN with versioned URLs, and private photos get short-lived signed links after an access check. Upload, processing and deletion are tracked workflows. Packing small files into volumes, Haystack-style, is an optimisation I'd add only when measurements justify it."

Historical context. The topic draws on Facebook's published Haystack design. Haystack grouped many photos into larger storage files and kept a compact lookup index, to cut file-metadata work. Its architecture included directory, cache and store components. It is a historical design described in 2010, not a claim about Facebook's current infrastructure (original Haystack paper). The design below is an original interview design for the broader storage problem, not a reconstruction of Haystack.

1. The picture and its description live apart

Data Example Typical home
Original bytes Uploaded photograph Durable blob storage
Derived bytes Thumbnail and display-size image Blob storage and caches
Product metadata Owner, album, visibility, caption Application database
Storage lookup Object ID to volume and location Storage index or object service
Workflow state Uploading, processing, ready, deleting Application database

A blob is a chunk of binary data treated as one object.

  • Product metadata answers "May Sunita's aunt view this photo?"
  • Storage lookup answers "Where are its bytes?"

Mixing the two makes both privacy changes and storage moves harder. To start, use an existing object store plus a relational metadata database. A custom storage engine is justified only when measured workload and cost show existing storage isn't enough.

Photo storage system: step 1, upload and storeStep 1 of 3: Upload and store. Components: Client, Upload workflow, Authorization and metadata, Photos, owners, visibility, Originals. The client uploads a photo; the service checks ownership, records it, and stores the original. CLIENT PHOTO SERVICE METADATA STORE BLOB STORE Client uploads bytes directly, views through URLs Upload workflow Authorization and metadata Photos, owners, visibility Originals start upload owner? create record bytes, signed link call service data store security, network people, apps, external
Step 1: the smallest design that works.

You've reached the free preview of this post.

Subscribe to the Blogs plan (₹99/mo) — or use any Algomi Suite, Career, Investor, or Trader plan — to keep reading.

See plans

Sources

System Design Case Studies · Part 7 of 15
Designing a CDN: Put Popular Content Near Its ReadersDesigning a Job Scheduler: Remember the Work, Expect Retries