As asked
Design a group chat application that supports 100,000 concurrent users across 1,000 chat rooms. Walk me through the data model, how you handle WebSocket connections at scale, message persistence, and delivery guarantees.
Sample answer outline
Use Phoenix Channels with PubSub per room topic. Scale horizontally with a Redis PubSub adapter (or pg adapter within a BEAM cluster). Messages persist to PostgreSQL with an append-only messages table. Delivery is at-most-once via PubSub; for guaranteed delivery, store message ID in the client and re-fetch since-last-seen on reconnect. Presence for online indicators. Consider Oban for asynchronous processing (notifications, indexing).
Expect these follow-ups
- How would you handle a user's unread message count across devices?
- What happens to in-flight messages during a node rolling restart?