[nanomsg] Re: Loadbalancer with async backend

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Fri, 22 Nov 2013 11:03:32 +0100

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 22/11/13 10:51, Stefan de Konink wrote:
> On Fri, 22 Nov 2013, Martin Sustrik wrote:
> 
>>> I am looking for a way to have a synchronised req/rep to a
>>> broker, and a series workers that could handle requests. The
>>> fundamental problem with this method is that I can't track the
>>> request at the frontend to guarantee that the reply arrives at
>>> the right socket.
>> 
>> Why not have a central device to dispatch the request? I.e. each 
>> client has a REQ socket, each worker has a REP socket and there's
>> a device in the middle everyone connects to.
> 
> I think my problem is that I don't know how to do the connection 
> tracking within the dispatcher.
> 
> When receiving req_1, sending req_1 to the worker as req_1',
> receiving the reply of req1', and replying to req1 the operation is
> synchronous. req_1..n will wait until the req_{n-1} is handled
> otherwise I cannot guarantee the reply to the right socket... or
> can I?

Yes, you can. In fact nanomsg does that for you. How it works is that
the path back to the original requester is stored in the message, but
it's done under the hood so you don't see this additional data
associated with the message. You simply send and receive messages and
they get to the correct destinations automagically.

If you are interested in how it works exactly, you can check this
document:
https://raw.github.com/nanomsg/nanomsg/master/rfc/sp-request-reply-01.txt

Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSjyv0AAoJENTpVjxCNN9Y6dUIAKvS4P4S8G7oOtjrziqdJLLd
M4vn1qJbO/9UGisJfsq5MIO/zwi1RSTmmtSiz06x3Ydzl8QO0qISOHzx6LRzOMED
LDpF4G4Jfp3GNytbF/ae1i4ouk7xGG5tR48ZtYE7UeRojb+jWmJOELIoGd9xAIQX
vTnYLeqsQytvf0Fg1F+gwaNiJg6I+dWSBhXJeaPQrI4gxvjg/yA8vlu+0XCDtlqb
omhL6x5sPl955LUdK4ts2yI0Kf9wamVT3PpI73vCfbMAV+4PJCs527sQ7aCFCwqv
sqfQK5tdREiRn2RoZypKe9fat1dP6QQuPBar0pFYaEitn5aaeyY/1Ml3NzJi1AY=
=Sazn
-----END PGP SIGNATURE-----

Other related posts: