Design Instagram Stories
Understanding the Problem
⏳ What are Instagram Stories? Stories are short photos and videos that disappear 24 hours after they're posted. They appear in the story tray, a horizontal row of avatars at the top of the app, one per followed account with something new to watch. Tapping an avatar plays that account's stories in order, then moves on to the next account in the tray.
Stories reuse a lot of the Instagram feed (follows, media upload, a CDN) but change the shape of the problem in three ways. Content has a hard 24-hour lifetime. The unit of the tray is an account, not a post. And every view matters: the viewer's ring turns grey once they've watched, and the author can see who viewed. That last one turns a read-heavy feature into a write-heavy one.
Functional Requirements
Core Requirements
- Users should be able to post a story (a photo or a short video) that expires 24 hours later.
- Users should be able to see a story tray: the accounts they follow that have active stories, with unseen ones first, paging as they scroll sideways.
- Users should be able to watch an account's stories in order, tapping forward and back, and auto-advance to the next account in the tray.
- Viewers should see which stories they've already watched, and authors should see who viewed each of their stories.
Below the line (out of scope)
- Replies, reactions, polls and stickers.
- Ads inserted between stories.
- Close Friends audiences (we'll note where an audience check goes).
- Highlights, beyond making sure expiry doesn't destroy the author's own archive.
Non-Functional Requirements
Ask your interviewer for scale. We'll assume 500 million daily users of Stories, 200 million new stories a day, and that a typical user watches around 30 stories a day.
Core Requirements
- A story must never be shown to viewers after it expires. Expiry should be exact from the user's point of view, even if cleanup happens later.
- The system should load the tray in under 200ms and start playing a story with no visible wait, including when tapping to the next one.
- The system should be highly available. A new story can take a few seconds to show up in followers' trays.
- The system should handle 15 billion views a day, each one updating seen state and a viewer list.
- Tray order should be stable while the user is looking at it. Avatars shouldn't jump around between pages.
Below the line (out of scope)
- Exact real-time view counts. A view count that lags by a few seconds is fine.
- Cross-region strong consistency.
The arithmetic:
- Posts: 200M stories / 86,400s ≈ 2,300 stories/s.
- Tray loads: 500M users × ~15 app opens ≈ 7.5B a day, about 87k/s.
- Views: 500M × 30 = 15B views a day, about 175k/s on average and several hundred thousand per second at peak. Each view is a write.
- Live media: at around 1MB per story (photos smaller, videos larger), the live set at any moment is the last 24 hours of stories, about 200TB. It churns completely every day.
Views outnumber new stories by about 75 to 1, and unlike likes, almost every view produces a write. That changes where the effort goes. Posting a story is the easy part; the tray and the view tracking are where the scale is.
A good opening move is to notice that Stories has two different "feeds." The tray is a per-viewer list of accounts, and each account's reel is a short list of stories. Keeping them separate makes fan-out much cheaper: an author who posts ten stories in an hour changes one tray entry per follower, not ten.