system design · system-design

Design Instagram (Photo Upload + Feed + Stories)

Photo upload + feed + stories + search/explore + hashtags. E5+ Meta product-design canon.

hard4hgeneralsystem-design
Ask GPTConfidence

Theory

Explanation

Intuition first, formal definition second. Skim the bullets if you already know this; read the prose if you don't.

Photo platform = upload pipeline + per-user follow graph feed + ephemeral stories overlay + explore/search. Each subsystem reuses primitives (CDN, fan-out, ranking) tuned for image workloads.

Upload: client uploads original to ingest service → multi-resolution variants generated → CDN distribution. Feed: same fan-out hybrid as News Feed but image-heavy. Stories: separate ephemeral store with 24h TTL, per-friend recency ordering. Explore: precomputed ranked grid per user via offline pipeline + online rerank. Search: inverted index over hashtags + usernames + place tags.

When to use

Photo / video social products.

When not to

Text-only feeds (chat apps).

flowchart LR
  Up[Upload] --> Ingest[Ingest Service]
  Ingest --> Variants[Variant Encoder]
  Variants --> CDN[Image CDN]
  Ingest --> Meta[(Metadata)]
  Meta --> Fan[Feed Fan-out]
  Fan --> Inbox[(Per-user Inbox)]
  User([User]) --> Feed[Feed API]
  Feed --> Inbox
  Feed --> Reco[Explore Reco]
  User --> Stories[Stories API]
  Stories --> StoryStore[(Stories · 24h TTL)]

Key insights

  • Multi-resolution variants encoded once at upload, saves CDN bandwidth on retrieval.
  • Stories ranking is recency-biased among friends; feed is engagement-biased.
  • Hashtag explore = inverted index from hashtag → top posts by engagement.
  • Search vs Explore: search is intent-driven (typed query); explore is passive (algorithmic grid).
  • Image CDN dwarfs everything else in cost, optimize cache hit rate aggressively.