
π System Design Interview Classics Β· Sequence
How a one-to-one chat message is delivered in a WhatsApp-style system, with sent, delivered and read ticks, and push notifications when the receiver is offline.
Drawing diagramβ¦
Chat message sequence: Alice's app sends a message over its WebSocket to chat server 1, which stores it in Cassandra and acknowledges (one tick). The presence service says which server Bob is on. If Bob is online, chat server 2 delivers it and Bob's app acknowledges (two ticks). If Bob is offline, a push notification is sent and the message is delivered when he reconnects. When Bob opens the chat a read receipt goes back (blue ticks).
sequenceDiagram
actor A as Alice
participant CS1 as Chat Server 1
participant DB as Message Store
participant PR as Presence Service
participant CS2 as Chat Server 2
participant PN as Push Service
actor B as Bob
A->>CS1: Send message over WebSocket
CS1->>DB: Store message
CS1-->>A: Sent - one tick
CS1->>PR: Where is Bob?
alt Bob online
PR-->>CS1: On Chat Server 2
CS1->>CS2: Forward message
CS2->>B: Deliver
B-->>CS2: Delivered ack
CS2-->>A: Delivered - two ticks
else Bob offline
PR-->>CS1: Offline
CS1->>PN: Send push notification
PN-->>B: New message alert
end
B->>CS2: Opened chat
CS2-->>A: Read - blue ticksThe classic interview design for a service like bit.ly: short code generation, fast redirects from a cache, and click analytics processed separately.
How posts reach followers' feeds: fan-out on write for normal users, fan-out on read for celebrities, and a ranked feed built from a cache.
The core of a ride-hailing app: drivers stream their locations, a geo index finds nearby drivers, and a matching service offers the trip to the best one.
How a token bucket rate limiter decides whether to let an API request through, using Redis so all servers share the same counts.
A notification system that sends email, SMS and push messages at scale: one API, a queue per channel, user preferences, and retries.
How search suggestions appear as you type: a prefix index built offline from past searches, served from memory, and refreshed regularly.