Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis: how (or should) I delete pubsub channels

In my app I dynamically create new pubsub channels and there might be too many like 5k per day. According to my app's requirements any channel is used for at most 5minutes.

Considering this situation, thousands of unused channels will be present in the app in a week. So how can I delete unused channels or should I even delete them. Do they stored in memory? What happens to the messages published via them, do they stay on the redis' memory?

thanks

like image 775
destan Avatar asked May 16 '13 10:05

destan


People also ask

Is Redis good for Pubsub?

Aside from data storage, Redis can be used as a Publisher/Subscriber platform. In this pattern, publishers can issue messages to any number of subscribers on a channel. These messages are fire-and-forget, in that if a message is published and no subscribers exists, the message evaporates and cannot be recovered.

How many channels can Redis have?

There is no hard limit in Redis on maximum number of channels; it is user configurable. Save this answer.

Does Redis Pub/Sub persist data?

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.

What is a channel in Pubsub?

A Publish-Subscribe Channel works like this: It has one input channel that splits into multiple output channels, one for each subscriber. When an event is published into the channel, the Publish-Subscribe Channel delivers a copy of the message to each of the output channels.


1 Answers

Channels are ambient. They only exist while there are subscriptions. So: either call [P]UNSUBSCRIBE from the connections that subscribed, or close the connections that subscribed.

like image 159
Marc Gravell Avatar answered Sep 21 '22 13:09

Marc Gravell