Design an Enterprise Multi-Tenant Messaging Platform
Design isolated organization messaging with ordered conversations, search, presence, read cursors, and offline delivery.
Problem statement
Design an enterprise messaging platform with direct messages, public, private, and invite-only channels, durable history, read receipts, presence, search, and offline push. Strictly isolate every organization's data and enforce permissions on the server.
Use long-lived client connections, conversation-partitioned ordered message storage, and server-assigned per-conversation sequence numbers. Represent read state as one per-user per-conversation cursor to avoid per-message write amplification.
Tenant-scope the inverted search index and filter by conversations visible to the user. Compare separate databases, tenant schemas, shared tenant-keyed tables, and a hybrid isolation model.
For this exercise, assume 100,000 organizations, 20 million concurrent connections, two million messages per second, p99 send acknowledgement below 500 ms, and seven-year configurable history retention.
What to build
- Authorized members create direct or channel conversations and manage public, private, or invite-only membership.
- Members send messages, read ordered durable history, advance one read cursor per conversation, and observe read state.
- Members receive best-effort presence, tenant-scoped authorized search, and offline push notifications without exposing message content across organizations.
At scale
- Source-backed behavior: servers assign per-conversation sequence numbers and store messages partitioned by conversation.
- Source-backed isolation: every database, search, presence, and authorization path is organization-scoped.
- Practice assumption: 100,000 organizations sustain 20 million connections and two million messages per second.
- Practice assumption: p99 send acknowledgement is below 500 ms and organization policy may retain history for up to seven years.