This is how Pub/Sub works performance wise in Redis.
You have two things.
1) Subscribers to channels (SUBSCRIBE)
2) Subscribers to *patterns* (PSUBSCRIBE)
3) Publishers (PUBLISH)
You can consider the work of subscribing/unsubscribing as a constant
time operation, O(1) for both subscribing and unsubscribing
(actually PSUBSCRIBE does more work than this if you are subscribed
already to many patterns with the *same* client).
All the complexity on the end is on the PUBLISH command, that performs
an amount of work that is proportional to:
a) The number of clients receiving the message.
b) The number of clients subscribed to a pattern, even if they'll not
match the message.
This means that if you have N clients subscribed to 100000 different
channels, everything will be super fast.
If you have instead 10000 clients subscribed to the same channel,
PUBLISH commands against this channel will be slow, and take maybe a
few milliseconds (not sure about the actual time taken). Since we have
to send the same message to everybody.
Also, if you have clients subscribed to 10000 *patterns* publish will
be slower than usually, but the work to do for every existing pattern
is smaller compared to the work that there is to do for every client
*receiving* the message.
About memory, it is similar or smaller than the one used by a key, so
you should not have problems to subscribe to millions of channels even
in a small server.
Salvatore
> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to
> redis-db+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/redis-db?hl=en.
>
--
Salvatore 'antirez' Sanfilippo
open source developer - VMware
http://invece.org
"We are what we repeatedly do. Excellence, therefore, is not an act,
but a habit." -- Aristotele
So the initial subscribe in your described case would be slow to
finish, but the actual publishing would be fast.
- Josiah
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/groups/opt_out.