Team chat and support chat
Messages fan out to every server holding a member's connection, and the stream gives newcomers the backlog.
Fan messages out to every connected client in real time, with sharded channels for clusters and streams for history.
Each WebSocket server subscribes to the rooms its connected users are in.
An animated walkthrough with real HotKV commands and example replies. Click any step to jump to it.
A chat room or live notification feed has to reach every connected user at once, across many WebSocket servers. Polling a database is too slow and too expensive, and the servers need a shared way to tell each other that something happened.
Each WebSocket server subscribes to the channels its users care about. When anything happens, one PUBLISH reaches every subscribed server, which forwards it to its users. Sharded channels keep the traffic on the node that owns the channel in a cluster, and a stream next to each room keeps the history for users who join later.
Each WebSocket server subscribes to the rooms its connected users are in.
SUBSCRIBE room:42Her server publishes once. The reply is how many subscribers received it.
PUBLISH room:42 "{\"from\":\"alice\",\"text\":\"Deploy is green\"}"The message is also appended to the room's stream, capped at the last 1000 messages.
XADD room:42:history MAXLEN ~ 1000 * from alice text "Deploy is green"He reads the last 50 messages from the stream, then goes live on the channel.
XREVRANGE room:42:history + - COUNT 50In cluster mode, SPUBLISH keeps the message on the node that owns the channel.
SPUBLISH room:{42}:typing "alice"Messages fan out to every server holding a member's connection, and the stream gives newcomers the backlog.
Order updates, mentions and alerts are pushed to the browser the moment they happen.
Cursor positions and typing indicators are broadcast on short-lived channels.
One publish reaches every subscriber.
PUBLISHSUBSCRIBESubscribe to room:* to receive every room.
PSUBSCRIBEChannels stay on the node that owns them in a cluster.
SPUBLISHSSUBSCRIBEPair a channel with a capped stream for messages users missed.
XADDXREVRANGENo. Pub/sub delivers to whoever is subscribed at that moment. Use a stream next to the channel if users need history.
Yes. Use sharded pub/sub (SPUBLISH, SSUBSCRIBE) so each channel's traffic stays on the node that owns it.
Yes. Keyspace notifications publish events for key changes. See the docs on keyspace notifications.
HotKV speaks the Redis protocol, so you can point an existing client at it and run these same commands.