Q30: How would you design a chat system?
Use WebSocket connections or another persistent transport for real-time delivery, with an authenticated connection gateway. Store messages durably before acknowledging them, partition conversations by conversation ID, and track per-conversation sequence or ordering metadata. Maintain delivery/read receipts, reconnect cursors, offline push notifications, and presence with expiring heartbeats. Define retention, encryption, abuse controls, and behavior when a user has multiple devices.
Key Takeaways
- Persist before acknowledgment and support reconnect catch-up.
- Presence is ephemeral; message history is durable.