System Design Interview: Whiteboard & LLD Blueprint
Master the 45-minute WhatsApp system design interview: how to structure your whiteboard walkthrough, explain the Erlang actor model, and write decoupled low-level design contracts.
In 30 seconds: In a 45-minute WhatsApp system design interview, success comes down to two clear blueprints: sketching a clean, decoupled whiteboard architecture (Layer 4 passthrough, Erlang actor gateways, sub-2ms in-memory session ring, and ephemeral spool) and writing low-level object-oriented class contracts with monotonic state transitions. Articulating the golden invariant—WhatsApp is an ephemeral store-and-forward pipe, not a persistent historical document database—immediately separates staff-level candidates from the crowd.
01The Hook: How to Stand Out in 45 Minutes
Imagine standing at the whiteboard or facing an excalidraw canvas at a top tech company. The interviewer looks up and says: "Design WhatsApp. You have 45 minutes. Walk me through the high-level architecture, then write the low-level object contracts for routing messages between 500 million active sockets."
Most candidates stumble in the first ten minutes. They draw a giant relational database in the center, attach an API gateway, suggest storing every chat message permanently in PostgreSQL or Cassandra, and attempt to poll for incoming messages over HTTP.
Within five minutes, the interviewer knows the candidate does not understand real-time messaging:
- Chat messages are not HTTP request-response pairs; they require long-lived bidirectional sockets.
- Storing petabytes of permanent message history on server disks bankrupts the infrastructure and destroys privacy.
- Relational queries cannot look up active socket descriptors across hundreds of edge nodes within single-digit milliseconds.
To pass a senior or staff-level interview, you must lead the conversation with structured pacing, concrete trade-offs, and clean architectural separation.
02How to Structure the 45-Minute Interview
A disciplined 45-minute interview should follow a strict cadence:
| Phase | Time | Candidate Objective |
|---|---|---|
| 1. Clarify & Scope | 0 to 5 min | State functional and non-functional requirements, traffic scale, and explicit out-of-scope boundaries. |
| 2. High-Level Design (HLD) | 5 to 20 min | Sketch the core whiteboard diagram (Ingress, Edge, Registry, Spool) and trace the five-step message journey. |
| 3. Low-Level Design (LLD) | 20 to 35 min | Detail UML classes, actor interfaces, monotonic delivery enums, and write clean domain code on the board. |
| 4. Bottlenecks & Edge Cases | 35 to 40 min | Analyze offline spool drainage, split-brain session lookups, and network reconnection storms. |
| 5. Wrap-Up & Trade-Offs | 40 to 45 min | Summarize the golden invariants and answer final interviewer questions. |
In the opening five minutes, explicitly state the Golden Invariant: "WhatsApp is an ephemeral store-and-forward message pipe, not a permanent database archive. As soon as the recipient acknowledges delivery, the message is permanently deleted from server infrastructure."
03High-Level Design (HLD) Whiteboard Architecture
When sketching your high-level architecture on the whiteboard, organize your components into five clean, decoupled tiers: Client Devices, Layer 4 Load Balancers, Erlang BEAM Edge Gateways, the Distributed Session Registry, and the Ephemeral Spool Buffer.
The Five-Step Whiteboard Walkthrough
Guide your interviewer through the end-to-end data flow using these exact five milestones:
- Edge Ingress and Connection Termination: Explain that clients maintain persistent TLS 1.3 sockets. Emphasize that Layer 4 balancers use consistent hashing to forward raw TCP packets directly to backend edge nodes without terminating TLS at the proxy layer. This eliminates half the socket allocations and avoids proxy CPU bottlenecks.
- Actor-per-Socket Isolation: Describe how the Erlang/BEAM runtime assigns a lightweight actor process (consuming only 2 to 4 KB of memory) to each open file descriptor. This architecture allows a single bare-metal server to sustain over 2 million concurrent live sockets without thread exhaustion.
- Session Resolution in O(1) Time: Point to the Distributed Session Registry. Explain that the cluster never queries a relational database to locate a recipient. An in-memory consistent hash ring maps user phone numbers to active gateway node addresses in under 2.5 milliseconds.
- Immediate Server Acknowledgment: Detail how the edge node returns an immediate server acknowledgment (
ack_server) back to the sender before contacting the recipient. This converts the client interface from a clock icon to a single grey tick, reassuring the user that the server infrastructure owns delivery responsibility. - The Ephemeral Invariant: Conclude with the platform's core storage rule. If the recipient is online, the message forwards directly to their edge node over inter-node RPC and vanishes from memory upon receipt. If the recipient is offline, the server spools the ciphertext in an append-only commit log with a 30-day expiration, triggers a silent alarm push via APNs or FCM, and executes a hard delete the millisecond Bob reconnects and acknowledges receipt.
04Low-Level Design (LLD): UML Class Model
After establishing the high-level architecture, senior interviewers will ask you to zoom into the low-level object model: "What core interfaces, actor abstractions, domain models, and state representations would you build to handle connection multiplexing and message routing?"
The UML class diagram below details the object-oriented structure and actor contracts that drive the edge tier:
Core Domain Interfaces and Class Contracts
In your code walkthrough, define the core domain boundaries using clean, decoupled interfaces:
package com.veltoryx.whatsapp.domain;
import java.util.List;
import java.util.Optional;
public record NodeLocation(String host, int port, String nodeId) {}
public interface ISessionRegistry {
Optional<NodeLocation> lookup(String userPhone);
void register(String userPhone, NodeLocation location);
void heartbeat(String userPhone);
void deregister(String userPhone);
}
public interface ISpoolService {
void enqueueOffline(MessagePacket packet);
List<MessagePacket> drainBatch(String userPhone, int batchLimit);
void deleteAcknowledged(List<String> messageIds);
}Next, define the immutable message entities and state representations:
package com.veltoryx.whatsapp.domain;
public enum MessageState {
PENDING(0), // Clock icon on client SQLite
SENT_TO_SERVER(1), // Single grey tick on sender UI
DELIVERED(2), // Double grey tick on sender UI
READ(3), // Double blue tick on sender UI
EXPIRED_DROPPED(4); // 30-day offline TTL tombstone
private final int rank;
MessageState(int rank) {
this.rank = rank;
}
public boolean canTransitionTo(MessageState next) {
return next.rank > this.rank;
}
}
public record MessagePacket(
String messageId,
String senderPhone,
String recipientPhone,
byte[] ciphertextPayload,
long timestampMs,
MessageState status
) {
public boolean isExpired(int ttlDays) {
long ttlMillis = ttlDays * 86_400_000L;
return (System.currentTimeMillis() - timestampMs) > ttlMillis;
}
}05Design Patterns in Real-Time Messaging
When the interviewer asks: "What software design patterns are you applying in this low-level design?", highlight these three:
- The State Pattern (Monotonic Tick Lifecycle): Message status transitions follow a strict monotonic order (
PENDING->SENT_TO_SERVER->DELIVERED->READ). A higher logical state permanently supersedes any out-of-order receipt. If a delayedDELIVEREDacknowledgment arrives after aREADreceipt has already updated the message entity, the state machine silently discards the stale packet. - The Actor Pattern (Erlang Process Isolation): Rather than using thread pools that contend on locks, each connection runs within an isolated
ConnectionWorkerActor. Crashing a single user actor due to a corrupted network packet never crashes the parent gateway or sibling connections. The BEAM supervisor tree restarts the actor instantly. - The Strategy Pattern (Offline Storage Backends): The
ISpoolServicedecouples message routing logic from the physical storage implementation. In local development or testing environments, the router uses an in-memory ring buffer. In production clusters, it swaps in a persistentCassandraSpoolServicepartitioned by the recipient phone number hash.
06Whiteboard Live-Coding: Message Router Implementation
When asked to write out the message routing logic on the board, show a clean, thread-safe implementation that orchestrates session lookup, online forwarding, and offline spooling:
package com.veltoryx.whatsapp.service;
import com.veltoryx.whatsapp.domain.*;
import java.util.Optional;
public class MessageRouter {
private final ISessionRegistry sessionRegistry;
private final ISpoolService spoolService;
private final PushNotificationClient pushClient;
public MessageRouter(
ISessionRegistry sessionRegistry,
ISpoolService spoolService,
PushNotificationClient pushClient
) {
this.sessionRegistry = sessionRegistry;
this.spoolService = spoolService;
this.pushClient = pushClient;
}
public RouteResult route(MessagePacket packet) {
// Step 1: Look up recipient active session in O(1) time
Optional<NodeLocation> recipientNode = sessionRegistry.lookup(packet.recipientPhone());
if (recipientNode.isPresent()) {
// Step 2a: Recipient is online -> forward to edge node over inter-cluster RPC
boolean delivered = forwardToRemoteNode(recipientNode.get(), packet);
if (delivered) {
return RouteResult.deliveredOnline(recipientNode.get());
}
}
// Step 2b: Recipient is offline -> spool ciphertext and dispatch silent push
spoolService.enqueueOffline(packet);
pushClient.sendSilentWakeup(packet.recipientPhone());
return RouteResult.spooledOffline();
}
private boolean forwardToRemoteNode(NodeLocation node, MessagePacket packet) {
// Implementation forwards raw ciphertext frame across internal data center backbone
return true;
}
}07In the interview
- How do you prevent split-brain routing if two gateways believe they own Bob's session? The session registry uses epoch generation numbers on socket registration. The gateway with the higher epoch wins, and the stale gateway forcefully closes its orphaned socket.
- Why avoid database transactions on message dispatch? At 3 million messages per second, distributed ACID transactions would exhaust database lock pools and degrade latency. Routing decisions rely on idempotent client UUIDs and append-only commit logs.
- How does the server handle duplicate delivery receipts? The client state machine is strictly monotonic. If a duplicate delivery packet arrives for a message already in
DELIVEREDorREADstate, it is safely ignored.
08Check your understanding
Quiz · 4 questions
0 of 4 answered
1. What is the primary architectural trade-off of delegating chat history storage exclusively to client devices?
2. Why does the Erlang BEAM actor model scale more effectively for connection gateways than Java thread pools?
3. How does the message delivery state machine handle receiving a READ receipt before a delayed DELIVERED receipt?
4. Why do WhatsApp push notifications (APNs / FCM) omit the message text and sender name in their payload?
What you now know
You have mastered the complete blueprint for presenting WhatsApp in a system design interview:
- How to structure the 45-minute discussion across requirements, high-level whiteboard architecture, low-level design, and edge cases.
- How to guide the interviewer through the five-step whiteboard walkthrough with clear infrastructure boundaries.
- The low-level domain interfaces (
ISessionRegistry,ISpoolService,MessageRouter) and design patterns (State, Actor, Strategy) that govern real-time message routing. - The golden invariants that separate real-time ephemeral messaging platforms from persistent document databases like Slack or Discord.
In the next module of the System Design Case Studies track, we turn from real-time messaging to hyperlocal logistics: Swiggy: Hyperlocal Food Delivery and Fleet Orchestration.