Design 24-Hour Ephemeral Stories for a Photo and Video Sharing App
MetaSoftware Engineer · OnsiteLast updated
A system design question on ephemeral stories that followers can view for 24 hours before they disappear, covering media upload, the tray of accounts with unwatched stories, playback, and viewer tracking. It tests expiry semantics, fan-out for popular authors, watched-state storage, and media delivery.
Design the stories feature of a photo- and video-sharing app. Users post photos or short videos as stories that their followers can view for 24 hours, after which the stories disappear. At the top of the app, each user sees a tray of followed accounts that have stories they have not watched yet; tapping an account plays that account's active stories in order.
Constraints and Clarifications
- Media processing (transcoding, thumbnails) and a CDN can be assumed to exist as building blocks; design how the feature uses them.
- Scale and latency targets are not given; ask for them or state assumptions.
Clarifying Questions
- How many daily active users are there, how many stories are posted per day, and what are the typical and largest follower counts?
- Can authors see who viewed each story, and must view counts be exact?
- Are restricted audiences, such as a close-friends list, in scope?
- What are the maximum video length and the supported upload formats?
- Must "watched" state sync across a viewer's devices?
Hints
Hint 1
What happens at the deadline: Think about what must be true exactly at the 24-hour mark and what can safely happen later in the background.
Hint 2
The tray is the hot path: The tray loads on every app open; think about what it needs to know per followed account and how small that can be.
Follow-up questions
- How would you rank the accounts in the tray?
- An account with a very large following posts a story. What load does that create for tray updates and for viewer-list writes?
- How would you let authors keep selected stories visible on their profile beyond 24 hours?
- How do you guarantee an expired story is never shown, even when some caches are stale?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.