Lesson Overview + Section #01 + RESHADED Checklist + Quiz #1 are unlocked free below (no login required). Unlock all 80 HD video lessons and deep-dive sections — or watch our two free sample video lessons first.
Designing a planetary-scale Newsfeed System (such as Facebook or LinkedIn) requires aggregating posts from heterogeneous sources—friends, groups, and public pages—into a personalized, ML-ranked stream for 1,000,000,000 daily active users (2,000,000,000 total users). Under an extreme 50:1 read-to-write asymmetry (116,000 feed loads/sec versus 2,300 new posts/sec), computing ranked feeds from disk on demand is infeasible. L4–L6 interviewers evaluate how candidates bound in-memory Feed Cache footprints (1.6 TB for 1B active users), isolate background feed generation from low-latency feed publishing, balance hybrid push/pull fan-out across 50M-follower pages, and implement two-stage relevance ranking.
WHAT YOU WILL MASTER IN THIS LESSON
Derive end-to-end capacity and RAM sizing under a 50:1 read-to-write workload (116K RPS reads, 2.3K RPS writes, 20 TB/day media, and 1.6 TB Feed Cache holding 200 8-byte post IDs per active user).
Architect decoupled Post Ingestion, Feed Generation, and Feed Publishing tiers backed by polyglot persistence (SQL, sharded KV, Graph DB, Blob/CDN, and Redis).
Combine hybrid fan-out (pushing to recently active friends while pulling 50M-follower pages at read time) with multi-signal relevance ranking (Affinity * Weight * Freshness evolving to two-stage ML).
Deliver cursor-paginated feeds from memory in < 200 ms alongside lightweight long-polling new-post notifications and pull-based cache-miss fallbacks.
Follow this exact sequence from the Intro narration on every system design prompt so you never miss requirements, math, contracts, or the 13-minute deep dive.
0 / 8 Checked
RRequirements & ScopeMin 2–8
Clarify who the users are, 3–4 core functional flows, explicit non-goals, and target latency/availability SLAs before drawing a single box.
Avoid trap: Still gathering requirements at minute 15 squeezes the deep dive where L5/L6 offers are decided.
EBack-of-the-Envelope MathMin 8–12
Compute ONLY numbers that actively change architectural choices: DAU → peak read/write RPS, daily & 5-year storage, bandwidth (or tokens/sec & KV-cache VRAM for AI).
Avoid trap: Spending 10 minutes multiplying irrelevant byte counts that never influence sharding or caching.
SStorage & Data ModelMin 12–15
Define core tables, primary/partition keys, and access indexes. Separate small structured metadata rows (~1 KB) from bulk binary blobs (S3 + CDN).
Avoid trap: Picking Cassandra or NoSQL by buzzword when 40 writes/s & 3 TB fit cleanly on one indexed SQL primary + replicas.
AAPIs & Wire ContractsMin 15–17
Write 3–4 concrete REST/gRPC/SSE/WebSocket endpoints with request/response shapes, cursor pagination, and Idempotency-Key headers on mutations.
Avoid trap: Hand-waving client-server contracts and discovering missing parameters halfway through the deep dive.
HHigh-Level DesignMin 17–27
Draw the simplest end-to-end working read and write paths first. Every box on the board must trace back to a stated requirement or number.
Avoid trap: Reciting a memorized 12-microservice Kafka mesh before proving why a simpler synchronous path breaks.
DDetailed Design (Deep Dive)Min 27–36
Proactively audit your high-level diagram, name the top 2 bottlenecks (hot partitions, fan-out skew, lock contention, GPU saturation), and go deep on internals.
Avoid trap: Waiting passively for the interviewer to rescue pacing or skimming every box at shallow surface depth.
EEvaluation & Failure ModesMin 36–41
State what each architectural choice COSTS you, and trace graceful degradation when cache, queue, external vendor, or primary DB fails.
Avoid trap: Assuming happy-path uptime or placing slow 3-second external calls inline on revenue-critical write paths.
DDistinctive FeatureMin 41–45
Solve the signature hard problem unique to this prompt (e.g., double-entry ledger idempotency, Geohash dispatch locks, OT/CRDT sync, or SSE token streaming).
Avoid trap: Spending 20 minutes on generic login/CRUD tables and zero time on the core distributed challenge.
INTERVIEWER SCORECARD · WHAT MAKES A STRONG HIRE?
5 Signals Bar Raisers Grade (L4 vs. L5 Senior vs. L6 Staff)
Senior (L5 / E5 / Senior SDE) Bar — Autonomous Pacing, Depth & Proactive Trade-Offs: Owns the 45-minute clock without prompting, derives every component quantitatively, surfaces failure modes (hot shards, stampedes, dual writes) BEFORE being asked, and defends consistency vs. latency trade-offs.
1. Scoping
✓ STRONG HIRE SIGNAL
Clarifies users, read/write skew, p99 latency, consistency bounds, and explicit non-goals in minutes 2–8.
✗ NO-HIRE RED FLAG
Jumps straight into drawing load balancers and microservices at minute 2 without asking a single question.
2. Right-Sized Design
✓ STRONG HIRE SIGNAL
Starts with the simplest working architecture justified by the math (e.g., 1 NVMe SQL primary + replicas + Redis for 40 writes/s & 3 TB).
✗ NO-HIRE RED FLAG
Recites a memorized Kafka + multi-DC Cassandra diagram that contradicts their own traffic calculations.
3. Technical Depth
✓ STRONG HIRE SIGNAL
Drives deep into 1–2 hard bottlenecks (partition keys, hot-key mitigation, transactional outbox, KV-cache batching) at minute 27.
✗ NO-HIRE RED FLAG
Skims across 12 boxes at identical buzzword depth and runs out of time before the deep dive.
4. Explicit Trade-Offs
✓ STRONG HIRE SIGNAL
Uses 3-part reasoning: 'A queue here because SMTP spikes to 3 s; checkout stays <60 ms, and we accept eventual email delay + retry dedup.'
✗ NO-HIRE RED FLAG
Name-drops tools ('We put Kafka and ZooKeeper here') without stating the alternative or operational cost.
5. Communication
✓ STRONG HIRE SIGNAL
Thinks aloud every 30–45s, checks alignment at phase transitions, and treats 'What if X fails?' as a cue for where points are awarded.
✗ NO-HIRE RED FLAG
Goes silent for 5 minutes while drawing or defends a flawed assumption defensively when nudged.
ARCHITECTURE & DATA-FLOW SLIDES · SLIDE 1 OF 4Section 01: System Design: Newsfeed System
ARCHITECTURE / DATA FLOW DIAGRAM
SECTION 01 OF 1
1. System Design: Newsfeed System
★ FREE PREVIEW
Key Takeaway: Materialize per-user lists of 8-byte post IDs in a 1.6 TB distributed RAM cache via asynchronous hybrid fan-out, rank candidates by predicted engagement rather than strict timestamp, and serve paginated feeds from memory.
SECTION 01 DIAGRAMS · SLIDE 1 OF 4System Design: Newsfeed System
A social newsfeed merges updates from disparate publishing cadences—friends posting weekly, interest groups posting hourly, and news pages publishing every few minutes—ordered by predicted user interest rather than raw creation time. For 2,000,000,000 registered users with 1,000,000,000 DAU opening their feed 10 times daily (10,000,000,000 loads/day) and 1 in 5 users authoring 1 post daily (200,000,000 posts/day), reads outnumber writes 50:1. To render a feed within < 2 s over high-latency mobile networks, backend server execution must complete in < 200 ms (p99), trading strict global freshness for eventual consistency (<= 10 s propagation delay) and uninterrupted availability (AP). Crucially, storing 2008-bytepost_id references (1.6 KB) per active user requires 1,000,000,000 * 1.6 KB = 1.6 TB of cluster RAM—proving precomputed in-memory feeds are economically viable.
Functional Scope: Author text/photo/video posts with audience ACLs (friends, public, group), view a personalized ranked feed, receive foreground New Posts notifications, and mutate follow edges across friends, pages, and groups.
Non-Functional Priorities: < 200 ms backend latency, horizontal scalability across 2x peak traffic (232,000 RPS), zero post data loss, and graceful fallback when cache shards fail.
Metric
Derivation Formula
Calculated Estimate
Engineering Decision
Feed Read QPS
(1B DAU * 10 opens) / 86,400 s
~116,000 RPS avg (~232,000 RPS at 2x peak)
Serve feed pages strictly from Feed Cache + Post Cache in RAM
Post Write QPS
(1B DAU * 0.2 posts) / 86,400 s
~2,300 RPS avg (50:1 read-to-write ratio)
Invest compute at write time (fan-out) to make 50x more reads O(1)
Post Metadata Storage
200M posts/day * 1 KB
200 GB/day (~73 TB/year)
Store once in sharded KV/wide-column DB keyed by post_id
Media Blob Storage
(200M * 20% photos) * 500 KB
40M * 500 KB = 20 TB/day (~7.3 PB/year)
Offload binary blobs to S3 and serve via edge CDN
Feed Cache Footprint
1B active users * 200 IDs * 8 B
1.6 TB total RAM (~16–32 Redis nodes)
Cache only 8 B IDs + compact float scores for active (<= 30d) users
Stateless Web/Feed Fleet
232,000 peak RPS / 2,000 RPS per server
~116 servers peak (+ multi-region spares)
Separate stateless fleets for Post Service vs. Feed Publishing
API Specification, Polyglot Data Model & Decoupled Architecture
Client APIs authenticate via bearer JWTs and use monotonic cursor=<post_id> pagination so incoming top-of-feed posts never shift offsets or duplicate items mid-scroll, paired with a lightweight GET /v1/feed/new?since=<post_id> check for foreground toast badges. Beneath the API, five distinct data records map to specialized stores: User profiles in SQL, immutable/edited Post metadata in a sharded KV/wide-column store, typed Follow edges (friend, page, group) in a distributed Graph store, Media URLs pointing to object storage, and an ephemeral Feed Cache in Redis storing (post_id, score) tuples—never duplicating post text across millions of feeds. Architecturally, the Write Path (Load Balancer -> Web Auth/Rate-Limit Tier -> Post Service -> Post Store + Blob Store -> Async Queue) is physically isolated from background Feed Generation and latency-sensitive Feed Publishing so heavy fan-out spikes never degrade read p99 latency.
Pure Push (fan-out-on-write) multiplies 2,300 posts/sec by 300 average connections for ~690,000 Redis writes/sec—manageable until a public page with 50,000,000 followers posts, triggering 50M writes and wasting RAM on dormant accounts. Pure Pull (fan-out-on-read) avoids write cost but explodes 116,000 reads/sec * 300 followees into ~34,800,000 backend lookups/sec. A Hybrid model pushes posts only from ordinary users/groups to followers active within the past 14–30 days, while pulling and merging high-follower pages on read. Once candidates are gathered, chronological sorting is replaced by Relevance Ranking: a classic baseline multiplies Affinity (interaction closeness with author), Weight (media engagement multiplier, e.g., photo 2.0 vs. link 1.0), and Freshness (time-decay factor <= 1.0). Production feeds evolve this into a two-stage ML pipeline—computing initial scores at write time and running neural re-ranking strictly over the top 200 cached candidates at read time.
Candidate Post
Author Affinity
Content Weight
Time-Decay Freshness
Final Score (`A * W * F`) & Rank
Best friend's photo (5 h ago)
0.9 (high interaction)
2.0 (rich photo)
0.5 (5 h decay)
0.90 -> Rank #1 (Top of Feed)
Classmate's status (1 h ago)
0.5 (moderate)
1.0 (plain text)
0.9 (1 h decay)
0.45 -> Rank #2
News page link (just now)
0.3 (passive follow)
1.0 (outbound link)
1.0 (0 h decay)
0.30 -> Rank #3 (Despite newest)
Interview Signal: ML Ranking Latency Budget: Never score 10,000+ raw posts with a heavyweight deep neural network synchronously on GET /v1/feed. Use lightweight retrieval/push to Bound the candidate pool to ~200–500 IDs in Feed Cache, then run feature-hydrated ML re-ranking in < 40 ms.
On GET /v1/feed, Feed Publishing reads the next 20 ranked post_ids after cursor from Feed Cache, batch-fetches full post bodies and author summaries from Post Cache (falling through to Post Store only on misses), and returns JSON containing CDN URLs so mobile clients download images/video in parallel from edge servers. To notify open apps of fresh content without 1,000,000,000 blind 1-minute polling loops (nearly 100% empty responses) or 1B dedicated chat-grade WebSockets, a lightweight Notifier pushes compact invalidation signals over adaptive long-polling or shared HTTP/3 multiplexed connections while the app is foregrounded—illuminating a tap-to-refresh New Posts pill rather than jarring the viewport mid-scroll. If a user's Feed Cache shard fails or evicts due to inactivity, Feed Publishing transparently falls back to pull-based reconstruction.