Medium · Media and streaming
Short-video feed
People swipe through an endless feed of clips of 10 to 30 seconds. The next clip must already be on the phone before the swipe. One clip can suddenly get millions of views, and every view is a signal that picks what to show next. Practise this medium system design problem for free with a Google or GitHub account.
The brief
People swipe through an endless feed of clips of 10 to 30 seconds. The next clip must already be on the phone before the swipe. One clip can suddenly get millions of views, and every view is a signal that picks what to show next.
Think of a short-video app like TikTok.
Users, scale and requirements
- Who uses it
- 2 million people a month
- Audience in plain numbers
- 2,000,000 people per month
- Normal peak
- ≈ 1,500 requests per second
- Request mix
- Stream chunk: 55%; Read: 25%; Analytics event: 12%; Search: 4%; Write: 3%; Upload: 1%
- Speed for 99 of 100 requests
- Stream chunk: ≈ 1,000 ms; Read: ≈ 450 ms; Search: ≈ 450 ms; Write: ≈ 450 ms; Upload: ≈ 6,000 ms
- Successful requests
- 99.8%
- Data safety
- At most 1 minute of writes may be lost.
- Monthly budget
- ≈ $170,000
- Data at rest
- ≈ 120 TB
- Where users are
- North America: 40%; Europe: 30%; Asia Pacific: 30%
- Home region
- North America
- Waiting deadlines
- Stream chunk: 900 seconds; Read: 900 seconds; Analytics event: 3,600 seconds; Search: 900 seconds; Write: 3,600 seconds; Upload: 3,600 seconds
≈ marks an approximation, just as in the game. Waiting deadlines measure the age of queued work and are separate from interactive response time.
- A short clip is about 6 MB in total, which the game counts as a few 2 MB chunks (approx.).
Questions that shape the design
Does the app start loading the next clip early?
Yes. The phone prefetches one or two clips ahead. That means fewer stalls but more data sent per viewer.
Is the feed the same for everybody?
No. Every person gets a ranked list picked just for them from a huge pool of clips.
How soon should a new clip show up?
Within a minute for the creator and their followers. Everyone else can wait a bit.
Can we lose a "like" or a view count?
A few can be late or missing. A posted clip's file sits in object storage, which keeps it safe; at most the last minute of new posts may need posting again after a failure.
The traffic day
Consumer traffic, busiest in the evening. The clock covers 00:00 to 24:00 in the home region. Events add pressure on top of that normal traffic.
20:15 · Viral spike
A post blows up. Traffic climbs to several times normal within minutes.
Traffic reaches 5 times the scheduled load; rises over 600 seconds, holds for 3,600 seconds and eases over 3,600 seconds.
20:20 · Hot key
One item gets a huge share of traffic: a celebrity profile, one product, one merchant.
Affected share: 40%. Duration: ≈ 3,600 seconds.
11:00 · Slow dependency
An outside service slows down. Your servers fill with requests waiting on it.
Added response time: ≈ 3,000 ms. Duration: ≈ 1,800 seconds.
What a strong design has to handle
- One clip can get a huge share of all views for an hour. Where in your design does that clip live?
- Separate personalized ranking from reusable video and bounded prefetch.
- Prefetching the next clip makes swiping feel instant but sends data the viewer may never watch. That extra bandwidth is a real line on the bill.
- Caching the ranked feed for a minute is cheap but makes the feed slightly less fresh. A fresh-for-you feed costs a recommender call on every swipe.
Make a prediction, run a full traffic day, then compare the result. The in-game editorial opens after a finished day and includes measured reference designs.
Concepts to practise
Related problems
- Easy
News site
You run a news site. Millions read the same few stories, and when something big happens almost everyone opens the same page in the same minute. Editors publish all day, and readers expect fresh headlines.
- Medium
Music streaming
People search for songs, build playlists and press play. The audio is the heavy part, and a hit song is played by millions at once. Playback must not stutter, even when part of your system fails.
- Easy
Comments and likes
Under every post sits a like counter and a comment list. Millions tap the heart on the same famous post at the same moment. Showing the exact number is not essential, but showing the person their own like is.
- Hard
Social feed
Every person opens the app and sees a feed of posts from the people they follow. Most people have a few hundred followers, but a few have millions, and when they post, millions of feeds must change. The feed must be fast and your own post must show up at once.