There is command for this in redis. Check out PUBSUB NUMSUB:
Returns the number of subscribers (not counting clients subscribed to patterns) for the specified channels.
And PUBSUB NUMPAT:
Returns the number of subscriptions to patterns (that are performed using the PSUBSCRIBE command). Note that this is not just the count of clients subscribed to patterns but the total number of patterns all the clients are subscribed to.
Edit: It's also worth noting that the PUBLISH command also returns number of receivers:
Return value
Integer reply: the number of clients that received the message.