Problem
Design the frontend of the Facebook News Feed: a personalized, never-ending list of posts (text, photos, video, link previews) that people scroll, react to, comment on and share, while counts change and new posts arrive in the background.
Interviewers use it to test how you load a ranked, ever-changing list without duplicates or gaps, keep a long scroll fast and stable on a cheap phone, make reactions and comments feel instant without counting anything twice, and measure what people actually saw.
Functional requirements
- Scroll a personalized feed that keeps loading as you go.
- React, comment and share, and see counts change, including other people's reactions.
- Create a post with text, photos or a video.
- Hear about new posts without losing your place.
Constraints
- The first post is on screen within 2.5 seconds on a mid-range phone, and a reaction or comment shows in under 100 ms, whatever the network is doing.
- Scrolling runs at 60 frames per second through sessions of 500+ posts, and nothing jumps while you read.
- Counts on the posts on screen update within about 5 seconds; one post can collect millions of reactions.
- No reaction, comment or post is lost on a flaky connection, and the feed opens offline from the last copy.
- A post or ad counts as seen only if it really was on screen, exactly once. Accessible to WCAG 2.2 AA: keyboard, screen reader and touch.
Discussion areas
- Core entities and key actions: what the feed, feed items, posts, media and comments are, and which user actions shape the design.
- Architecture and rendering: whether a logged-in feed should render on the server or the client, the layers between UI components and the server, and the component tree.
- Data model: how posts, users and comments live in the client store, and how the feed's order is kept.
- Pagination: loading a ranked feed that keeps changing without repeats or skips.
- New posts: telling the reader about new posts without moving what they're reading.
- Reactions and comments: showing them instantly, undoing only what failed, and keeping counts right when many people react at once.
- API and live updates: endpoints for loading and writes, and how live counts reach the posts on screen.
- Errors and offline: which failures to retry and which to give up on, and what the feed shows offline.
- Performance: a long scroll with posts of different heights, images and video that never shift the page, and autoplay.
- Impressions and accessibility: counting what was really seen, and using the feed with a keyboard and a screen reader.
Follow-up questions interviewers ask
- Why cursor pagination and not offset or page numbers?
- Why SSE and not WebSockets?
- Why not insert new posts at the top as they arrive?
- What if Asha taps Like five times quickly?
- What if a live count arrives while Asha's like is in flight?
- Why server-render a logged-in page at all?
- Virtualization or
content-visibility: auto? - How do several open tabs work?