← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 011 · Messaging and event-driven systems

Design a Real-Time Chat Service

Medium 50 min

Design the backend for a chat app. Users send messages to individuals or groups of up to 500 people. Messages must arrive within a second when the recipient is online, be stored so users can scroll back through history, and never be lost once the sender sees them as sent.

Functional requirements

  • Send and receive one-to-one messages
  • Group chats of up to 500 members
  • Scroll back through message history
  • Show who is online

Non-functional requirements

  • Messages reach online recipients in under 1 second at p99
  • No message is lost once acknowledged to the sender
  • Message order is preserved within a conversation

Constraints and scale

  • 50 million daily active users
  • 10 million concurrent connections at peak
  • 40 messages per user per day on average

You will practise

  • Choose a real-time transport (WebSockets) and scale stateful connections
  • Fan out group messages efficiently
  • Model message storage for fast history reads
Show 2 hints
  1. Persistent connections are stateful: how does a sender's server find the recipient's server?
  2. Write messages durably before acknowledging them.

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • A connection server crashesOne of the servers holding 200 000 live WebSocket connections dies without warning.

Run them from the workspace once your design is in place.