</> MAANG.io
system design · 101

Foundations

Master system design interviews with scalable architecture patterns, distributed systems, and real-world design challenges.

0/81 solved 0% complete

What Happens When You Send a Chat Message?

maang.io System Design Series


What is this?

You thumb out "on my way", hit send, and the little spinner barely flickers before a checkmark appears. A fraction of a second later — sometimes less — your friend's phone buzzes on a table across town, and "on my way" is sitting on their screen. The wild part: their phone was asleep a moment ago. Nobody was actively asking your server "any new messages for me?" The message just… arrived, pushed down to a device that wasn't even looking.

That tiny everyday moment quietly leans on half the 101 tier at once. A WebSocket holds the pipe open. A load balancer has to find the one server holding that pipe. A database makes the message durable before you're told it's sent. A message queue catches messages for people who are offline. And delivery semantics — at-least-once, dedup, idempotency — decide whether your friend sees "on my way" once, twice, or not at all.

The one-line idea: sending a chat message is a relay too, but a stateful one — your message rides an already-open connection, gets stored before it's acked, and is then either pushed straight down to an online friend or parked in a queue for an offline one, with receipts trickling back as their own little messages.

One important guardrail before we start. This lesson traces one message, end to end. It is not "design WhatsApp" — there's no capacity math, no schema design, no global multi-region architecture here. That full build is the 301 tier's job. We're staying firmly on the follow-the-message rail: where does this one "on my way" go, in what order, and which 101 building block owns each hop. Let's walk it.


Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.