[nanomsg] Re: Where "Channel ID" are managed in the code ?

  • From: Paul Colomiets <paul@xxxxxxxxxxxxxx>
  • To: "nanomsg@xxxxxxxxxxxxx" <nanomsg@xxxxxxxxxxxxx>
  • Date: Wed, 15 Jan 2014 16:00:16 +0200

Hi Laurent,


On Tue, Jan 14, 2014 at 11:50 AM, Laurent Alebarde <l.alebarde@xxxxxxx>wrote:

>  Le 14/01/2014 10:30, Paul Colomiets a écrit :
>
>
>
> Have you seen this thread?
> //www.freelists.org/post/nanomsg/Trying-to-implement-directory-pattern
>
>
> It's not implemented yet. But does it match your use case? It may better
> to invest time into this stuff, because presumably it serves more use cases
> than NN_REQ_SCHEDULER.
>
> From the opposite point of view if we add kinda NN_SHARDING option to all
> patterns, it may be interesting to have sharded patterns not only for
> request-reply (like directory patterns describes), but for pipeline and
> other patterns.
>
> --
> Paul
>
>
> Hi Paul,
>
> Thanks for the suggestion. But it does not fit my needs. In this
> "directory" pattern, the worker can subscribe to different request types.
> In my case, all clients send requests of the same type, so the only
> possibility with the "directory" pattern would be to subscribe to a set of
> clients. But it is not desired. When a client connects, I want to assign it
> the most available worker, and stick the client to the same worker. When
> the client has finished and disconnects, and reconnects say one day later,
> I want again to assign it the most available worker, which is not
> necessarily the same than the last time.
>

I think its possible to include some "client_id" (or hash of it) in the
request itself. Then arrange subscriptions in a way, that each client id
routed to some worker based on the hash of client_id. It has the following
advantages:

1. When worker dies, your monitoring system may notice it and update
subscriptions, in any sensible way for your particular system

2. Client ids may (or may not) be persistent across disconnections and
multiple connections (e.g. connection to multiple router devices for
load-balancing or failover)

Comments?

-- 
Paul

Other related posts: