Reputation: 3322
I am trying to create chat rooms app and use redis pub/sub broadcasting messages across subscribers. Each meeting room is 1 channel. The problem is I can have infinite number of channels over time.
Upvotes: 0
Views: 2447
Reputation: 23041
Is there any limit for max number of channels I can have in redis?
Redis doesn't set any limit on the number of channels. Channels are saved into a hash, whose size is of type long
. So in theory, the limit is 2**63
on a 64 bits machine. However, since your memory is limited, you cannot reach the limit. In a word, practically, there's no limit.
Is there any way to auto expire/delete channels which have not received any messages for publishing?
There's no way to do that. Redis deletes a channel, only when all clients of the channel have unsubscribed it, i.e. when a channel has no subscribers, Redis remove the channel automatically. If there's at least one client subscribing it, Redis keep the channel even if there's no message published to it.
Upvotes: 3