Katkat

Design a real-time chat system with hot groups

AirbnbSoftware Engineer · Onsite

Last updated

This problem tests your ability to design a distributed, low-latency messaging system that handles massive fan-out and identify trending group activities.

Design a Real-Time Chat System with 'Hot' Groups

Design a global real-time chat platform supporting 1:1 and group messaging. The system must support millions of concurrent users. A core requirement is to identify and cache 'hot' groups—groups with the highest message velocity—to optimize delivery performance.

Functional Requirements

  1. Send and receive messages in real-time.
  2. Support group chats with up to 10,000 members.
  3. Provide message history sync across multiple devices.
  4. Real-time delivery status (read receipts).
  5. Identify the Top 100 'hot' groups globally in near real-time.

Non-Functional Requirements

  1. Low latency: 99th percentile message delivery under 200ms.
  2. High availability and partition tolerance.
  3. Eventual consistency for message ordering.

Deliverables

  1. High-level architecture including API design and storage choices (SQL vs. NoSQL).
  2. Mechanism for real-time WebSocket connection management across a server cluster.
  3. A strategy for tracking and serving 'hot' groups without overloading the primary database.
  4. Handling message fan-out for large group chats.

Hints

Hint 1

Use a Pub/Sub mechanism combined with a distributed WebSocket gateway layer to route messages to users across different server nodes.

Hint 2

For 'hot' groups, consider using a sliding window counter approach with an in-memory data store like Redis to track message volume per group ID.

Hint 3

To handle large group fan-out, implement a broadcast strategy that separates the 'send' operation from the 'delivery' operation using a message queue.

Follow-up questions

  • How would you handle the 'thundering herd' problem if a single group suddenly becomes viral and message volume spikes 100x?
  • If users are in different geographic regions, how would you minimize latency for cross-region message delivery?
  • How would you ensure exactly-once delivery of messages in the event of a network partition?