Design Group Messaging Service
Difficulty: EASYCategory: DSAFrequency: 1Asked On 2022-06-11
Problem Statement
Designing a scalable group messaging platform (similar to WhatsApp Groups, Slack Channels, or Telegram Groups). The service should support real-time communication, large group participation, and message persistence across devices.
The focus of this round is to design the system architecture, data flow, and scaling strategy while discussing trade-offs in storage, delivery guarantees, and fault tolerance.
✅ Functional Requirements
1.<span></span>User & Group Management
2.<span></span>Users can create/join/leave groups.
3.<span></span>Groups can have multiple participants (up to N users).
4.<span></span>Support role-based controls (admin, member).
5.<span></span>Messaging
6.<span></span>Users can send text/media messages to a group.
7.<span></span>Messages must be delivered to all group members.
8.<span></span>Ordering of messages should be preserved within a group.
9.<span></span>Delivery Guarantees
10.<span></span>At-least-once delivery of messages.
11.<span></span>Read receipts (optional).
12.<span></span>Offline users should receive messages once online.
13.<span></span>Search & History
14.<span></span>Retrieve message history for a group.
15.<span></span>Search messages by keyword, sender, or date.
⚙️ Non-Functional Requirements
1.<span></span>Scalability → Handle millions of concurrent users and large groups.
2.<span></span>Low Latency → Messages should be delivered in near real-time.
3.<span></span>Durability → Messages should be stored persistently.
4.<span></span>Fault Tolerance → Ensure message delivery even in case of server failures.
5.<span></span>Consistency → Maintain ordering within a group.
🔐 Constraints
1.<span></span>Each group may have up to thousands of members.
2.<span></span>Message fan-out needs to be efficient (avoid N writes per message).
3.<span></span>System should support multi-device sync for users.
4.<span></span>Must consider rate limiting and spam prevention.
🎯 Discussion Areas
1.<span></span>Architecture
2.<span></span>Use of pub-sub systems (Kafka, Redis Streams, Google Pub/Sub) for fan-out.
3.<span></span>Backend services for group management, message routing, and delivery.
4.<span></span>Storage layer for message persistence (SQL vs. NoSQL).
5.<span></span>Data Modeling
6.<span></span>User table, Group table, Group Membership table.
7.<span></span>Message store (partitioned by group).
8.<span></span>Indexes for message retrieval & search.
9.<span></span>Scalability Strategies
10.<span></span>Sharding groups across servers.
11.<span></span>Efficient fan-out: push vs. pull models.
12.<span></span>Caching frequently accessed messages.
13.<span></span>Reliability
14.<span></span>Message acknowledgments & retries.
15.<span></span>Handling offline delivery (store-and-forward).
16.<span></span>Dead-letter queues for failed deliveries.
17.<span></span>Trade-offs
18.<span></span>Push vs. pull delivery (real-time vs. resource usage).
19.<span></span>Strong ordering guarantees vs. scalability.
20.<span></span>SQL (structured, consistency) vs. NoSQL (scale, flexibility).
21.<span></span>Eventual consistency for read receipts vs. strong consistency (performance hit).
👉 The candidate is expected to design the overall system architecture, model core entities, and discuss scaling strategies for group messaging, while reasoning through trade-offs in message delivery guarantees, ordering, and system reliability.