System designInterview preparation
Advanced·System design·2 min read

How would you design a chat system?

Practice this question

Short explanation:

A chat service delivers messages to connected users while preserving enough state for offline users and reconnects. Persistent storage provides history, and WebSockets provide timely delivery to active connections. Message IDs, ordering rules and acknowledgements let clients recover without displaying duplicates or losing unseen messages.

Key points:

  • Use authenticated WebSocket connections for online updates.

  • Store messages durably with IDs and per-conversation ordering.

  • Track delivery/read state separately and support reconnects with missed-message fetching.

  • Persist a message before claiming durable acceptance and track read receipts separately from transport delivery.

  • Partition work by conversation where appropriate; a global message order is usually unnecessary and expensive.

Interview point:

  • Explain how a reconnecting client resumes from its last known message and checks access to the conversation.
Adapted from 07_SYSTEM_DESIGN_ARCHITECTURE.md · “How would you design a chat system?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.