KatInterview

Build a Messaging Platform with Instant and Offline Delivery

System DesignModel answer
MediumModel answerSystem Designmessagingreal-timedistributed-systems

Last updated

Design an instant messaging system supporting direct and group chats with real-time delivery, offline queuing, and cross-device history sync.

You're building a messaging platform for a consumer application. The platform needs to support both direct conversations between two people and group chats with multiple participants. Your design should handle:

  • Messages delivered instantly to recipients who are currently connected
  • Messages queued for recipients who are offline, delivered when they come back online
  • Full conversation history accessible from any device a user logs in from
  • Text messages (assume no media for initial scope)

Consider a scale of 100 million daily active users, with each user sending an average of 50 messages per day. Group sizes typically range from 3-50 members, with some large groups reaching 1,000+ members.

Your interviewer wants to understand:

  1. How you'll maintain persistent connections and route messages to the right recipients
  2. Your storage strategy for conversations and message history
  3. How you'll handle message ordering, deduplication, and reliability
  4. Your approach to offline delivery and syncing across multiple devices
  5. How group messages scale, especially for large groups
  6. Trade-offs in your design and what breaks at extreme scale

Walk through your high-level architecture, key components, data models, and API contracts. Discuss failure modes and how your system handles them.

Hints

Hint 1

Think about the lifecycle of a message from send to delivery - what needs to happen at each step and which components are involved?

Hint 2

Consider how you'll maintain a mapping from user ID to their active connection endpoints, and what happens when that mapping is stale.

Hint 3

For groups, evaluate whether you fan out at write time or read time, and how the group size influences that decision.