Real-time & Messaging
Pushing data the moment it changes — WebSockets, fan-out, streaming and message queues — across chat, feeds, notifications and collaborative editing.
Handbooks 6
The Kafka Handbook
Apache Kafka as a distributed append-only log, not a queue — topics, partitions and offsets, producers, consumers and consumer groups, per-key ordering, replication and ISR, delivery semantics (at-least-once and exactly-once), retention vs log compaction, and when Kafka beats a message queue.
Kafka vs RabbitMQ
They both "move messages", which is exactly why teams pick the wrong one. Kafka is a durable, replayable log where consumers track their own offset; RabbitMQ is a smart broker that routes each message and deletes it on ack. The remember-vs-forget core difference, throughput and ordering trade-offs, and how to choose.
The WebSockets & Real-Time Handbook
Why "live" is hard on a protocol that can't push. Polling makes you wait on average half the interval to learn of an event (a 10s poll = ~5s staleness) and wastes a request every time nothing changed — and shrinking the interval only multiplies the waste. A WebSocket keeps one persistent full-duplex line open so the server pushes the instant something happens: latency ≈ one network hop, zero empty requests. The poll-vs-push latency math, when to use SSE instead, and the stateful-scaling pitfalls. With worked math and runnable code.
Kafka vs Kinesis
Same partitioned-log model underneath, different operational surface: Kafka is self-run and portable with a huge ecosystem; Kinesis is fully AWS-managed with a hard per-shard throughput ceiling. Retention, cost model, and the lock-in trade-off.
REST vs Webhooks vs SSE
Three ways client and server move data, split by who exposes an endpoint and whether the connection stays open: REST pulls, webhooks flip who runs the server, SSE keeps one connection open for a live push. How real systems run all three at once.
Streaming vs Batch
Batch processes on a schedule; streaming reacts per-event. The real engineering cost of streaming isn’t speed, it’s correctness under disorder — event time vs processing time, watermarks, exactly-once semantics. The Lambda and Kappa architectures that combine both.
System Designs 20
Design Uber
Build a planet-scale ride-hailing system. Learn how to handle real-time location tracking, matching algorithms, scalability, and payments.
Design WhatsApp
Build a real-time messaging system. See how persistent WebSockets, a session registry, offline inbox queues, the ✓✓ delivery receipts, group fan-out, media on a CDN, and end-to-end encryption fit together.
Design Twitter
Build Twitter's news feed. Learn the social graph, why fan-out on write beats read-time merging, how a precomputed timeline cache makes feed reads O(1), how ranking surfaces the best tweets, and how a hybrid model solves the celebrity problem.
Design a Notification System
Build a multi-channel notification system. See how one API, a message queue and a worker fleet decouple slow third-party delivery, how preferences and quiet hours gate every send, how templates fan out to push, SMS and email, and how delivery tracking, retries, dedup and rate limits keep it reliable.
Design a Message Queue
Build a distributed message queue like Kafka. See how an append-only commit log, partitions keyed for order, consumer groups with server-side offsets, leader/follower replication, controller-driven leader election, retention and compaction, and exactly-once guarantees fit together.
Design a News Feed
Build a social news feed. See how the social graph, pull vs push fan-out, a precomputed feed cache, relevance ranking, the hybrid model that tames the celebrity problem, blending multiple content sources, and cursor pagination fit together.
Design Google Docs
Build a real-time collaborative editor. See how edits become tiny operations, how OT and CRDTs resolve concurrent edits so every copy converges, how ops broadcast over WebSockets, how an op log plus snapshots give history and recovery, and how presence, offline sync and per-document sharding fit together.
Design Netflix
Build a planet-scale video streaming service. See how the play path splits authorization from byte delivery, how origin storage and CDN edges serve immutable segments, how an adaptive-bitrate ladder adapts to any connection, how a parallel transcoding pipeline builds it, and how Open Connect, recommendations and QoE events fit together.
Design Instagram
Build a photo-sharing app. See how splitting media from metadata, a CDN for immutable images, async image processing, a precomputed feed cache, asynchronous like/view counters, TTL-based ephemeral stories, and sharding fit together to serve billions of photos.
Design an Ad Click Aggregator
Build a real-time ad click aggregator. See how a thin ingest API and event stream absorb millions of clicks a second, how a stream processor aggregates into time windows, how dedup keys give exactly-once counts, how a raw event lake and batch recompute reconcile the numbers, and how fraud filtering and watermarks handle the sharp edges.
Design Slack
Build a team chat app. See how channel messaging and per-channel history, real-time delivery over WebSockets with a session registry, cross-server fan-out via pub/sub, ephemeral presence and typing, message search, unread counts and notifications, and channel sharding fit together.
Design a Leaderboard
Build a real-time leaderboard for millions of players. See why SQL ORDER BY + COUNT rank melts at scale, how a sorted set (Redis ZSET) gives O(log N) update/rank and O(log N + K) top-K, how relative "around me" boards work, why sharding a global ranking is uniquely hard, how time-windowed boards reset cleanly, and how a durable store backs the rebuildable in-memory index.
Design a Fraud Detection System
Build a real-time fraud detection system like Stripe Radar. See why static rules fail against an adaptive adversary, how real-time features (velocity, device, geo) from a feature store carry the signal, how an ML model blends with rules under an ~80ms budget, how streaming aggregations keep features fresh, how the chargeback/label feedback loop retrains the model, and how allow/deny/step-up decisioning and graph features handle nuance and fraud rings.
Design a Video Conferencing System
Build a video conferencing system like Zoom or Google Meet. See why real-time media needs UDP/WebRTC not TCP, why a peer-to-peer mesh explodes at N², how an SFU lets each peer upload once and forwards streams, how simulcast adapts quality per receiver, how signaling with SDP and ICE/STUN/TURN connects peers across NATs, and how geo-distributed cascaded SFUs scale to huge global calls.
Design a Live Streaming System
Build a live video streaming system like Twitch or YouTube Live. See why it optimizes for cheap CDN fan-out instead of ultra-low latency, how ingest accepts one broadcaster push, how transcoding builds an adaptive bitrate ladder, how HLS/DASH segmenting turns live video into cacheable HTTP files, how a CDN fans them to millions, the latency-vs-scale dial, and how live chat and DVR/VOD fit in.
Design a Food Delivery System
Build a food delivery system like DoorDash or Uber Eats. See why it's a three-sided marketplace plus a real-time logistics engine, how the order lifecycle is a durable state machine, how the dispatch engine optimizes courier assignment (who and when, not nearest-now), how location tracking and geo-indexing work, how ETA is an ML sum of prep + travel + wait, and how geo-sharding and surge balance supply and demand.
Design a Collaborative Editor
Build a real-time collaborative document editor like Google Docs, Notion or Figma. See why a whole-document lock kills concurrency, how naive position-based edits corrupt a document, how Operational Transformation's central sequencer works and where it bottlenecks, how CRDTs remove that bottleneck with causal, order-independent merges, why presence/cursors live outside the document's durable history, and how offline-first editing and tombstone garbage collection round out the design.
Design a Calendar System
Build a shared calendar like Google Calendar or Outlook. See why storing every recurring occurrence explodes storage, how RRULE-based recurrence is expanded at read time with exceptions layered on top, how free/busy conflict detection stays fast via interval overlap, the timezone/DST trap that can silently shift a recurring meeting by an hour, how invite/RSVP fan-out avoids blocking the organizer, how reminders scale via a time-bucketed trigger index, and how devices sync incrementally.
Design a Dating App
Build a swipe-based dating app like Tinder or Hinge. See why a live full-table nearby scan doesn't scale, how a geospatial index plus a swiped-exclusion set fixes candidate generation, the mutual-match race condition and how a database uniqueness constraint guarantees exactly one match, how ranked feeds are precomputed rather than live, why blocking is deliberately the strictest-consistency path in the whole system, and how bot/fake-profile detection runs quietly, asynchronously, off the hot path.
Design a Ride-Matching Engine
Build the matching and dispatch engine at the heart of a ride-hailing platform — the specific subsystem deciding which driver gets which rider, not the trip lifecycle or payments. See why straight-line distance is a bad proxy for real ETA, why greedy one-at-a-time matching is globally suboptimal, how batch matching solves an assignment-optimization problem across a short window, surge pricing as supply/demand balancing, ingesting driver locations at write-heavy scale, and fairness for idle drivers.
AI System Designs 2
Design a Conversational AI
Build a production conversational AI system (think ChatGPT). See how the request path splits an inference gateway from the model servers, how the context window is assembled and token-budgeted, how conversation memory is stored and recalled, how tokens stream back over a persistent connection, and how guardrails gate every prompt and response.
Design Realtime Speech Translation
Build a live speech-to-speech translator, chaining streaming ASR, MT, and TTS under a tight latency budget. See why record-then-translate feels like a walkie-talkie, streaming partial transcripts, why streaming translation must revise its own output as more context arrives, chunking policy, voice/prosody preservation, disfluency filtering, per-stage latency budgeting, and code-switching.
Algorithm Games 5
The Last One Standing: Boyer-Moore Majority Vote
Don't memorize the majority vote — watch the votes cancel out. Find the value that appears more than half the time in one pass with just two variables: keep a candidate, add for a match, cancel for a mismatch, and whoever survives is the majority. O(n) time, O(1) space, works on streams — plus full theory, the code and a quiz.
The Fair Draw: Reservoir Sampling
Don't memorize reservoir sampling — watch it stay fair. Pick one element uniformly at random from a stream of unknown length, holding just one slot: keep the i-th arrival with probability 1/i, and every element ends up equally likely. The one-pass, O(1)-space trick behind sampling logs and huge files — plus full theory, the code and a quiz.
Bloom Filter: Maybe Yes, Never No
Don't memorize the Bloom filter — play it. Add items by lighting k bits with k hashes, then query: all bits set means 'probably present', any bit unset means 'definitely absent'. Hunt down a live false positive and see why a Bloom filter can give a false yes but never a false no — the tiny, key-less probabilistic set behind caches, databases, and crawlers. Made playable, with theory and a quiz.
Count–Min Sketch: Counting in Tiny Space
Don't memorize the Count–Min Sketch — play it. Count how often items appear in a stream using a fixed grid of counters and d hashes: bump one cell per row on each event, and estimate a frequency by taking the minimum across rows. Watch a collision inflate an estimate, and see why it can over-count but never under-count — the structure behind heavy-hitters and streaming analytics. Made playable, with theory and a quiz.
MinHash: Similarity in a Signature
Don't memorize MinHash — play it. Estimate the Jaccard similarity of two sets by comparing k tiny hash-based signatures: for each hash, the minimum value over a set's elements matches between two sets with probability equal to their Jaccard similarity. Add hash functions and watch the estimate converge on the true overlap. The trick behind near-duplicate detection at web scale — made playable, with theory and a quiz.
Coding Challenges 2
Reservoir Sampling
Pick k items uniformly at random from a stream of unknown length — one pass, O(k) memory. Here the random draws are supplied, so the result is deterministic and testable. Solve it in Python or TypeScript, with hidden tests.
HyperLogLog Cardinality Estimator
Count how many distinct items a stream held — billions of them — using a few kilobytes, not a giant set. Turn "the longest run of leading zeros" into an estimate. Powers COUNT(DISTINCT) in Redis and BigQuery. Solve it in Python or TypeScript, with hidden tests.
Interactive Tools 1
About real-time & messaging
Some systems can't wait for the next request to show you what changed — a chat, a live feed, a collaborative document need updates pushed the moment they happen. That means persistent connections (WebSockets), fan-out to many subscribers, and streaming instead of polling.
Underneath sits message queues and event streams: the decoupling layer that lets a fast producer hand work to slower consumers without either blocking the other, and that turns "do it now, synchronously" into "publish an event, process it reliably later". This topic covers both the user-facing real-time surfaces and the messaging backbone that makes them dependable.