Redis Pub/sub unicast delivery

605 views
Skip to first unread message

darshan

unread,
Nov 22, 2016, 10:02:43 AM11/22/16
to Redis DB
Hi,
In my use case I have multiple subscribers for a single channel. Message published to that channel will be subscribed by all the subscriber. I did some research and came up with a crude solution to achieve unicast delivery.
I wanted to know if Redis supports Unicast delivery. If no, shouldn't it be a feature of Redis Pub/sub?

Jim Keener

unread,
Nov 22, 2016, 11:36:02 PM11/22/16
to Redis DB
What do you mean by unicast?  TCP or UDP unicast is what is being used (one sender one receivers).  Are you asking about UDP multicast (one sender, multiple receivers)?

Using multicast often requires the cooperation of the network administrator, but could be useful in this situation.  I'd also imagine the complexity of the new network code, e.g. using UDP sometimes and the lack of reliability guarantees in UDP potentially requiring some additional tooling and overhead would be major hurdles to getting it included. However, for high-volume channels where it's OK to drop some messages it could be an ideal solution.  At that point, though, I wonder if something like zmq might fit the bill better.

Jim

darshan

unread,
Nov 23, 2016, 3:05:55 AM11/23/16
to Redis DB
First of all, thank you for your detailed reply :)

What do you mean by unicast?
Sorry, wrong use of word 'unicast' here. What I really meant was, when there are multiple subscribers for a channel of Redis Pub/sub, only one (may be picked randomly or any other logic) of the subscribers should receive the published message and not all the subscribers.

Are you asking about UDP multicast (one sender, multiple receivers)?
No. My question is 'why redis pub/sub doesn't allow delivery of published message to only one subscriber among all the subscribers?'

Also, I don't think this feature has to do anything with network and reliability guarantees. Because, currently redis pub/sub mechanism is multicasting the published messages to all the subscribers. The feature I am discussing about, requires the message to be deleted from redis pub/sub soon after FIRST subscriber consumes the message. So that remaining subscribers won't consume the same message.
Hope this clears your doubts about my doubt ;)

Thanks once again.

Jesús Gabriel y Galán

unread,
Nov 23, 2016, 4:21:49 AM11/23/16
to redi...@googlegroups.com
While not 100% the same functionality, you could explore the BLPOP
command. You could have multiple clients performing a BLPOP on a list,
and when a producer inserts an element in the list, only one of the
clients will receive it.

Maybe this works for your use case.

Jesus.

darshan

unread,
Nov 23, 2016, 5:38:53 AM11/23/16
to Redis DB
I have come across that solution using BLPOP. But my use case requires event-based message consumption.
There was another solution which uses both LPOP on list and pub/sub for notification to subscribers. 
This second solution(more of a hack) works for me.

But I was wondering why implementing single delivery in redis pub/sub would be a bad idea.
Reply all
Reply to author
Forward
0 new messages