How it works
“Build chat” leaves important choices unanswered. For this design, assume text messages, one-to-one conversations, groups of at most 250 members, multiple devices per account, online indicators, and notifications when the app is away. Agree on a target audience, latency goal, history retention, and whether edits, attachments, or end-to-end encryption belong in the first release. Those are product differences, not just sizes: WhatsApp encrypts messages end to end by default, which rules out the server-side search that Slack offers.
Separate sending a message from receiving it. A sender needs an acceptance result; an online recipient should see the message quickly; an offline recipient should find it on return. These are three different promises. A green dot or push notification cannot stand in for durable message delivery.
Estimate active concurrent connections, messages per second at peak, average message size, and group fanout, meaning how many deliveries one message becomes. Registered accounts alone cannot size a connection fleet. As an example, take 30 million daily users, 10% connected at peak with 1.5 devices each: 4.5 million open sockets. At 40 messages per user per day, that is 1.2 billion messages, about 14,000 per second on average and 42,000 at a threefold peak. One message to a full group becomes 249 deliveries.
Carry uncertain numbers as assumptions and revisit them. A team chat for 500 people could run on one server and one database, so fleets of connection servers and sharding (splitting data across databases) would cost more than they return.
A team asks for “real-time chat” and says nothing about groups, devices, or offline users. What should the first design conversation establish?
Ask which conversation types matter, whether one account has several devices, what happens offline, how long history is kept, and what latency or load is expected. Record assumptions before choosing WebSocket or a store.
Use this as a guide for self review; written answers are not graded.Keep in mind
- State the exact chat product and first-release boundary.
- Define acceptance, live delivery, and later retrieval as separate outcomes.