Case 3
Delivery, Ordering, and Groups
Per-chat ordering, presence, and group fan-out define the server-side data model.
Group fan-out strategies
- Small groups (< 256): push to every member inbox on send.
- Large groups: store single copy; members pull on chat open.
- Typing indicators: gossip or pub/sub channel, lossy is acceptable.
Step-by-step walkthrough
Send path — persist message
- ① WebSocket SEND — Sender posts ciphertext over an open connection; payload stays small (no JSON bloat).
- ② Append seq=N — Chat server assigns a monotonic sequence number and appends to the replicated message store.
- ③ Update presence — Sender marked online in Redis with TTL; typing indicators use the same channel.
Delivery path — online or offline
- ④a Online: WebSocket PUSH — If receiver is connected, server pushes the message on their socket immediately.
- ④b Offline: notify — If receiver is disconnected, server triggers APNs/FCM instead of holding sockets open.
- ⑤ Push alert — Mobile OS shows notification; message ciphertext waits in the durable store.
- ⑥ ACK seq — Receiver acknowledges; server trims delivered messages from the hot queue.
fan-outsequencegroupspresenceRedisQPSconnections