Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does redis pub sub persist historical messages in a channel?

I haven't been able to find in the documentation on how the messages in a channel get stored in redis publish/subscribe.

When you publish to a redis channel, is that message stored or persisted? If so, how long is it stored and how do you get historical messages?

Otherwise, I'm assuming that it just broadcasts that message and drops/deletes that message after doing so?

like image 267
MonkeyBonkey Avatar asked Aug 06 '13 12:08

MonkeyBonkey


People also ask

Does Redis Pub/Sub persist data?

More precisely, Redis Pub/Sub is designed for real-time communication between instances where low latency is of the utmost importance, and as such doesn't feature any form of persistence or acknowledgment.

Does Redis Pub/Sub store messages?

Unlike most Redis operations, which may be written to disk, Redis pub/sub is non-persistent. Published messages are passed directly to subscribers and then dropped, with no record retained in Redis's memory or on disk.

How does Pub/Sub work in Redis?

Redis Pub/Sub implements the messaging system where the senders (in redis terminology called publishers) sends the messages while the receivers (subscribers) receive them. The link by which the messages are transferred is called channel. In Redis, a client can subscribe any number of channels.

How reliable is Redis pub sub?

The Redis pub/sub is not a reliable messaging system. Messages that are not retrieved will be discarded when your client is disconnected or a master/standby switchover occurs.


1 Answers

The pub/sub messages are not queued, and even less persisted.

They are only buffered in the socket buffers, and immediately sent to the subscribers in the same event loop iteration as the publication.

If a subscriber fails to read a message, this message is lost for the subscriber.

like image 90
Didier Spezia Avatar answered Oct 05 '22 10:10

Didier Spezia