TSTier SlateAll templates
  1. Home
  2. Templates
  3. Media feed

Social & feeds

Media feed - the feed serves URLs, the edge serves bytes

Why the feed serves URLs and the edge serves bytes, and who actually pays for the pixels.

  • System design
  • core
  • 8 step walkthrough
  • 5 tables
Own this board 400 creditsPractise as an interview

The first act plays here. Owned once with credits, never a subscription.

Share

  • Facebook
  • X

What this board gets wrong on purpose

The tension

The post is published synchronously and the renditions are made asynchronously, so there is a window - usually two seconds, occasionally twenty minutes when the queue backs up - in which a post exists and its thumbnails do not. The client falls back to the 2.5 MB original over cellular, which is the worst possible outcome on the worst possible connection, and nothing on this board measures how often it happens. The second half is the CDN: renditions are immutable and cached for a year, so a deletion or a takedown propagates only as fast as a purge API nobody has load tested, and the signed URL expiry is the only real revocation - which means the honest takedown latency is the token lifetime, six hours, not the moment somebody pressed delete.

Practise this as an interview

Take Media feed - the feed serves URLs, the edge serves bytes as a timed system design interview on a blank board - on your own, with the requirements to check yourself against, or with a candidate you invite.

Practise this as an interview

Start here

Why this design

A photo feed looks like a ranking problem and is really a bytes problem: the post record is about 700 bytes and the picture is about 3,000,000. Interviewers use it to see whether you keep megabytes off the application entirely - on the way in and on the way out - and whether you can say who actually pays for the pixels. Any product that serves user photos at scale lives or dies on the same three moves: direct upload, a fixed rendition ladder, and an edge that does the real work.

What you will learn

  • Why the upload is a pre-signed PUT straight to object storage, so 288 TB/day never passes through a service you deploy.
  • Why renditions are a fixed ladder of four, made once, immutable and cached for a year - and why resizing per request defeats the cache.
  • How the read path splits in two: the feed API serves 46,000 requests/s and ~0.4 GB/s of JSON; the edge serves 463,000 requests/s and ~55 GB/s of pixels.
  • Why egress (~4.8 PB/day, ~$35M/year) is the bill, and why the original is 87% of storage and read almost never.
  • Why publish does not wait for the transcode, and the honest window in which a post exists before its thumbnails do.
  • Why a takedown really propagates at the signed-URL lifetime (six hours), not at the moment of delete.

How to read this board

  1. Press play once: the walkthrough follows one photo from the camera roll to a stranger's screen.
  2. UPLOAD · THE BYTES NEVER TOUCH THE API (top row): ask for a slot, then PUT the bytes around the service.
  3. PROCESS · ASYNC, AND THE POST DOES NOT WAIT (second row): one file becomes four, and publish runs beside it.
  4. DELIVER · JSON FROM US, BYTES FROM THE EDGE (third row): eight kilobytes of JSON, then the wire from the edge to the phone that touches nothing of ours.
  5. THE DATA MODEL · GENERATE SQL READS THESE: media, renditions, posts and the disposable feed index.
  6. Then pages 1 to 6 in order: requirements, capacity, storage, availability, how it works, deployment.

1 · Requirements

Clarifying questions to ask first

  • Do we keep the original file forever, or only the renditions? This is the single biggest cost lever on the whole system and it is a product decision, not an engineering one.
  • Are images public or access-controlled? Public means long-lived immutable URLs and a CDN that needs no identity. Controlled means signed URLs, which means an expiry, which means a cache key that churns.
  • Which renditions does the client actually use, and who decides - server or device? A device that asks for arbitrary widths makes the cache useless.
  • What is the acceptable publish-to-visible lag? If it must be zero, the transcode cannot be asynchronous and the whole board changes.
  • Video too, or photos only? Video is a different pipeline with segmenting, multiple bitrates and a manifest. This board is photos.
  • What is the egress budget? See the capacity page - it dominates every other cost by an order of magnitude.

Functional

  • Upload a photo and publish a post referencing it.
  • Read a feed: a page of recent posts from accounts you follow, each with a displayable image URL.
  • Serve each image at the size the device needs, at the edge, worldwide.
  • Delete a post; the image must stop being served.

Non-functional

  • Feed API p99 under 150 ms. It returns a few kilobytes of JSON; there is no excuse for it to be slow.
  • Image time-to-first-byte p95 under 100 ms from the edge, with a 95%+ CDN hit rate.
  • Publish-to-renditions-ready p95 under 10 seconds.
  • 99.99% durability target on originals, 99.9% availability on the read path.
  • Upload must survive a flaky mobile connection: resumable, idempotent, retryable.

Explicitly out of scope

Ranking, stories, video, ads, comments, and the recommendation model. The feed order is drawn as one box.

The rest of this board

Preview of the Media feed system design board: 16 components joined by 20 connections. The labelled board opens in Tierslate.
Board preview

Available on Tier Slate

This page publishes the question. The answer — 5 more written pages, an 8-step narrated walkthrough and a 5-table schema — is the board itself, and it opens in Tierslate.

  • 5written pages
  • 8walkthrough steps
  • 5tables28 columns

5 pages behind this one

  • Capacity estimation
  • Storage estimation
  • Availability
  • How it works
  • Deployment plan
Open this board in TierslateBrowse every board

Related system design templates

Timelines, follows, fan-out - the read-heavy classics. 10 more social & feeds templates:

  • Social news feed system design - Fan-out on write against fan-out on read, and when each loses.
  • The professional graph system design - Why a degree badge on every name is a graph held in memory and searched from both ends, not a join.
  • Comment trees system design - How a whole comment tree comes back in one range scan, and why every vote rewrites what it cached.
  • The social graph system design - Why every follow is written twice on two shards with no transaction between, and what that drift costs.
  • Home timeline system design - Why one post is fanned out into hundreds of precomputed timelines, and why the celebrity cannot be.
  • Blog platform system design - Why a blog is a read-heavy system where the cache is the product, and what publishing has to invalidate.
  • Link previews system design - Why unfurling a pasted URL is a server-side request forgery problem first and a caching problem second.
  • Reviews and ratings system design - Why a star rating is an aggregate maintained on write, and how fake reviews are held back before they count.
  • Content moderation system design - Why moderation is a fast automatic gate plus a slow human queue, and what is shown while it decides.
  • Stories system design - Why expiry is a read-time filter plus a background sweep, and why the viewer list is the expensive part.
Open the Media feed board in TierslateAll social & feeds templatesAll 100 system design templates
Tierslate

tierslate.com

HomeTemplatesGuidesCompareAboutUI mockupsPrivacyTerms