Real-time chat that works across a cluster
The problem
LetSlic's mobile API forks one Node.js worker per CPU core. Socket.IO keeps its rooms in each worker's memory, so a phone connected to one worker never hears an event emitted on another. Without shared state the symptoms were the familiar ones: connection counts that read zero, messages that reached the server and stopped there, and online status that disagreed between screens.
What we built
- A shared adapter. Socket.IO runs on the Redis adapter, so a room means the same thing on every worker.
- A personal room per person. On sign-in every socket joins
user_<id>, across screens and devices. A message sent through the API is pushed to each recipient's personal room, not only to the chat's room, so it reaches someone on the chat list as well as someone with the thread open. Read receipts and per-recipient unread counts travel the same way. - Status before presence arrives. Last-active time is stored, so a chat header shows a sensible status before the live presence event lands, and the chat list refetches when the app returns to the foreground.
Group moderation
Groups carry their own moderation: roles assigned per member, mutes and bans with an optional end date, pinned or scheduled announcements with reactions and comments, written rules and invite codes. Staff can open any chat in the superadmin console, see its participants and their roles, and archive or delete it.



























