← All videos

Video guide

21:28 · 24 May 2024

Frontend System Design Interview Walkthrough: Build the Instagram Feed

Chapters 4 sections

  1. 0:00Introduction and Requirements Analysis
  2. 6:43Minimum Viable System Architecture
  3. 8:52Scaling the System Architecture
  4. 16:35Optimizing Client-Side Performance

Key concepts in this video:

  1. 1. Requirements & the Traffic Math

    Ask before assuming: web or mobile? Images only or video? Likes and comments in scope? You're judged on your questions, especially early.

    Then quantify: 1M daily actives, each posting once and consuming ~100 posts — a 1:100 read-to-write ratio you'll exploit later. 70% online in a two-hour evening peak ≈ 10K requests/second. 1MB per image means throughput is a problem too.

    Read/write ratioBack-of-envelopePeak traffic
  2. 2. The Minimum Viable System

    Web app → feed service → NoSQL database for post metadata, with images in blob storage (the service returns URLs, never the bytes).

    Get this on the board before optimizing anything. The interview goal isn't solving — it's showing how you think and keeping the interviewer bought in with open-ended questions.

    Blob storageNoSQLInterviewer buy-in
  3. 3. Scaling: CDNs and the Read/Write Split

    Two CDNs first: one for the app's static assets, one for images. That also removes single points of failure.

    Then split the feed service into a read service and a write service — the 1:100 ratio means the read side takes the beating, so scale it horizontally behind a load balancer while writes stay simple.

    Add a Redis cache for hot data: viral posts don't change, so serve their metadata from memory. Thumbnail generation goes async — a serverless job after upload.

    Read/write splitLoad balancingRedisAsync jobs
  4. 4. Defending the Database Choice

    NoSQL here — but the why matters more than the pick: posts have simple relationships (post → user, little else) and document stores scale reads with less ceremony.

    Complex relational data would flip the answer to Postgres or MySQL. Shape of the data first, scalability second.

    NoSQL vs SQLData shape
  5. 5. List Virtualization in the Client

    Infinite scroll means unbounded DOM growth — mobile browsers choke long before users stop scrolling.

    Unmount posts outside the viewport, keep placeholders so the scrollbar stays honest, and use IntersectionObserver (or a library like react-virtualized) as the sliding window.

    WindowingIntersectionObserverDOM pressure
  6. 6. Cursor-Based Pagination

    Page-number pagination breaks on a live feed: new posts push content down and page 6 repeats page 5.

    Cursor-based pagination anchors on a post id — "give me the next five after this one" — so fresh inserts can't shift what the user sees. Pair the cursor fetch with the same IntersectionObserver driving the virtualization.

    Cursor paginationFeed consistency
  7. 7. Knowing When NOT to SSR

    The feed is state-heavy and instantly scrolled — pre-rendering it buys almost nothing. The chrome around the feed? Pre-render away.

    Saying no to SSR with a reason is a stronger senior signal than reaching for it. Same for the five interview mistakes: assuming too much, losing the interviewer, running out of things to say, talking outside your depth, and drowning in implementation details.

    SSR trade-offsInterview mistakes

Transcript

So today we're going through a system design interview uh we're going to build a Instagram feed feature with a focus on the front end this is one of the most common system design interviews that you will encounter as a frontend or full stack developer we will also share with you the five most common mistakes developers make in system design interviews and a four-steps framework that you can use to solve any system design interview problem front end or backend bton are you ready yes let's go okay well I sent you a link with the instructions can you pull that up yeah okay so that's our task uh we are going