Skip to content
FLAVIO COPES
flaviocopes.com
2026

Redis Publish/subscribe

By Flavio Copes

Learn how Redis publish/subscribe messaging works, using the SUBSCRIBE and PUBLISH commands to send a message on a channel to multiple subscribers at once.

~~~

Redis implements a publish/subscribe messaging mechanism.

Its concept is simple: a publisher sends a message on a channel. Multiple subscribers receive it.

Subscribe to a channel using

SUBSCRIBE <channel>

Publish to a channel using

PUBLISH <channel> <message>

Example:

SUBSCRIBE dogs

Redis CLI terminal showing SUBSCRIBE dogs command with confirmation messages

In another redis-cli window, type:

PUBLISH dogs "Roger"

Redis CLI terminal showing PUBLISH commands sending Roger and Syd messages to dogs channel

Messages will be sent to the subscribers, and they’ll by default display the kind of event, the channel, and the message:

Subscriber terminal displaying received messages from dogs channel showing Roger and Syd

Subscribers can listen on multiple channels:

SUBSCRIBE dogs cats

and will receive messages coming from all of them.

Tagged: Redis · All topics
~~~

Related posts about redis: