Design Live Stream Chat
MediumSystem design · Realtime Messaging
Design live chat for a streaming platform where a single channel can have 1M concurrent viewers and 20K inbound messages/s at peak. Messages are disposable: only recent context matters and no human can read more than about 20 messages/s. Cover edge fan-out, deliberate sampling, ordering, moderation on the write path (bans, slow mode, automod), the recent-message buffer for joiners, and slow-client handling. Durable direct messaging is a different problem (see Chat Application and Slack).
Requirements
- Fan out through edge nodes that subscribe once per channel, not once per viewer
- Cap and sample the broadcast rate; keep only a small recent buffer, with a separate moderation archive
- Screen messages before broadcast, with ban state applied within seconds
- Drop messages for slow clients instead of buffering without bound