Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
All topics/System Design Case Studies
RELIABILITY, SECURITY & CASE STUDIES · SUBTOPIC

Case Study: Real-Time Chat (WhatsApp / Slack)

Persistent WebSocket gateways, Redis Pub/Sub routing, Cassandra message history, and offline push.

AdvancedPart of System Design Case Studies
Practice in AI HLD
Subtopics in System Design Case Studies (8)
OverviewURL ShortenerNews FeedChat AppUber / Ride-HailingYouTube / StreamingDropbox / DriveWeb CrawlerNotification System

In plain words

Every online phone keeps one live WebSocket connection open to a chat gateway. When Alice texts Bob, the gateway saves the message in an append-fast DB, checks Redis for Bob’s gateway, and pushes it live - or wakes Bob’s phone via Apple/Google push if offline.

Think of it like…

Live switchboard connecting open phone lines, backed by an answering machine (DB + push notification) when someone’s phone is off.

Loading interactive diagram
Loading interactive exercise

Theory & how it works

Group Chat Fan-out & Delivery Ticks

For small groups (≤500 members), fan out message notifications to each online member’s gateway via Redis Pub/Sub. Store messages with monotonic Snowflake IDs per chat_id so ordering is deterministic, and update per-user read watermarks for Sent ✓ / Delivered ✓✓ / Read ✓✓.

Key points & practical guide

Summary checklist

  • Use WebSockets + Redis Pub/Sub for cross-server live routing
  • Partition messages by chat_id ordered by Snowflake msg_id (LSM store)
  • Use APNs / FCM mobile push when recipient has no active socket

When to use it

  • 1:1 messaging, group chat, live support widgets

Watch out for

  • Storing user presence "online/offline" directly in SQL - use Redis keys with 30s heartbeat TTLs

Quick check

Loading quiz
Previous subtopic
Case Study: Social News Feed (Twitter / Instagram)
Next subtopic
Case Study: Ride-Hailing (Uber / Lyft)