PubSub implements Publish/Subscribe pattern where messages are sent to specific channels or channel patterns and are delivered to subscribers of those channels. This pattern decouples publishers and subscribers and allows publishers to sent messages without any knowledge about subscribers. Messages are broadcasted to all subscribers, not only to the first receiver.
Main use-case of PubSub is event notification; subscribers listen for events on some channels, publishers generate events due to some actions. Using PubSub system, you can implement;
A simple chat application, where chat rooms are the PubSub channels and each user in the chat room subscribes and publishes to the channel of the room.
A notification system for a multi-tenant application; to broadcast specific events or announcements. For instance a game server and its clients or a backend server and its frontend clients.
Most important limitation of the Redis PubSub mechanism is, it's a synchronous messaging system and it requires all subscribers to be active/online to be able to receive messages. There's no way of receiving earlier messages before the subscription time, there's no durability option while sending the messages.
Stay tuned 😉!