Design a Direct Messaging System for an E-commerce Marketplace
Design a direct messaging (DM) system for an e-commerce marketplace. Buyers and sellers need to chat directly with one another (one-to-one conversations) about listings, orders, shipping, and returns. Either side can start a conversation, and either side can be online or offline at any time.
The product is web-based only, but a single user may have the site open in multiple browser tabs or on multiple computers at the same time, and may log in from a new device at any moment.
The system must satisfy the following requirements:
- Real-time delivery: When the recipient is online, a message should reach them as quickly as possible (low end-to-end latency).
- Offline notifications: When the recipient has no active session, notify them out-of-band via SMS or email so they know a message is waiting.
- Cross-device consistency / durability: Message history must be durable and identical across all of a user's sessions. A message received or read on one device must not disappear or be lost on another device, including a device the user logs into later.
- Resilience to mid-delivery disconnects: If a recipient's device goes offline while a message is being delivered, the message must be queued and delivered when that device reconnects — never silently dropped.
- Simultaneous multi-device reads: The same user reading the same conversation from two devices at once must see a consistent view (ordering, read state) without duplicating or losing messages.
Constraints & Assumptions:
- ~50M registered users, ~5M daily active users.
- Mostly 1:1 conversations (buyer <-> seller). Group chat is out of scope for v1.
- Write volume on the order of ~10k messages/sec average, with peaks several times higher.
- Messages are short text (plus optional small attachments / links to listings); assume a few hundred bytes to a few KB each.
- Target online delivery latency: a few hundred milliseconds (p99) end-to-end. Offline notification latency of seconds is acceptable.
- Message history is retained long-term and must be searchable/scrollable per conversation.
- Reasonable abuse/spam controls exist but the deep anti-abuse design is out of scope.
AI interview prep
Core dilemma
Balancing real-time, low-latency delivery to potentially many concurrent, multi-device clients with guaranteed durability, consistency, and offline notification for a high-volume e-commerce messaging system.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design a Direct Messaging System for an E-commerce Marketplace
Design a direct messaging (DM) system for an e-commerce marketplace. Buyers and sellers need to chat directly with one another (one-to-one conversations) about listings, orders, shipping, and returns. Either side can start a conversation, and either side can be online or offline at any time.
The product is web-based only, but a single user may have the site open in multiple browser tabs or on multiple computers at the same time, and may log in from a new device at any moment.
The system must satisfy the following requirements:
- Real-time delivery: When the recipient is online, a message should reach them as quickly as possible (low end-to-end latency).
- Offline notifications: When the recipient has no active session, notify them out-of-band via SMS or email so they know a message is waiting.
- Cross-device consistency / durability: Message history must be durable and identical across all of a user's sessions. A message received or read on one device must not disappear or be lost on another device, including a device the user logs into later.
- Resilience to mid-delivery disconnects: If a recipient's device goes offline while a message is being delivered, the message must be queued and delivered when that device reconnects — never silently dropped.
- Simultaneous multi-device reads: The same user reading the same conversation from two devices at once must see a consistent view (ordering, read state) without duplicating or losing messages.
Constraints & Assumptions:
- ~50M registered users, ~5M daily active users.
- Mostly 1:1 conversations (buyer <-> seller). Group chat is out of scope for v1.
- Write volume on the order of ~10k messages/sec average, with peaks several times higher.
- Messages are short text (plus optional small attachments / links to listings); assume a few hundred bytes to a few KB each.
- Target online delivery latency: a few hundred milliseconds (p99) end-to-end. Offline notification latency of seconds is acceptable.
- Message history is retained long-term and must be searchable/scrollable per conversation.
- Reasonable abuse/spam controls exist but the deep anti-abuse design is out of scope.