Re: [zeromq-dev] DEALER to ROUTER and reusing identity.

2013-02-25 Thread Trevor Bernard
 I'd advise against trying to use identities to make this failover work.

Okay.

 You're going to be fighting 0MQ's autoreconnect. Instead, provide 
 authentication in the protocol itself and design the router app to do the 
 failover itself.

I don't understand what you mean when you say design the router app to
do the failover itself.

Some more info about my topology:

I know in advance who all the primary services are. And if a failover
scenerio happens, a leader election occurs and I will know about the
new primary's hostname and ports.

I can essentially do this:

zmq_connect(s, Service 234)
zmq_send (s, data, sizeof (data), 0);

The pattern I'm trying to implement is a reliable pipeline. I want to
be able to guarantee that what I send from the front endpoint won't be
lost on it's way to the back endpoint.

I use a pipeline to distribute the work/values and was toying with the
DEALER/ROUTER setup that was described earlier for acknowledgements.

This is my first attempt at the pattern:

https://gist.github.com/trevorbernard/5029260/raw/9ab008dd931f3dfc6ec435beb7f3039a02a0c9a0/gistfile1.txt

Looking forward to your feedback,

Trev
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] DEALER to ROUTER and reusing identity.

2013-02-25 Thread Pieter Hintjens
On Mon, Feb 25, 2013 at 1:24 PM, Trevor Bernard
trevor.bern...@gmail.com wrote:

 The pattern I'm trying to implement is a reliable pipeline. I want to
 be able to guarantee that what I send from the front endpoint won't be
 lost on it's way to the back endpoint.

OK, the simplest design is to assume that failure is possible in
workers due to them running application code, whereas ventilator and
sink are robust. Then, you detect failure by having a loss in the
sink, and you recover from failure by resubmitting the whole batch. If
it fails more than once, you flag it as toxic and stop retrying.

If you want to handle failed sinks or ventilators, you can use
redundancy and simply choose a sink/ventilator at start up, since
these are stateless.

You can do all this with PUSH/PULL I think.

Clearly you're trying something more sophisticated so my guess is
either we don't mean the same thing with reliable pipeline, or
you're building a too-complex solution.

My advice on reliability is to identify real failures and solve those
in order of probability.

-Pieter
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] DEALER to ROUTER and reusing identity.

2013-02-25 Thread Pieter Hintjens
On Mon, Feb 25, 2013 at 4:23 PM, Trevor Bernard
trevor.bern...@gmail.com wrote:

 All I want to do is send work upstream reliably and have the
 ventilator be notified by the sink through an acknowledgement if the
 batch was successful or not so I can take appropriate action.

 How would you suggest I go about this?

The ventilator can tell the sink directly how many jobs to expect. If
there's any missing after a timeout, that means a worker died. The
sink would then tell the client Failed and the client could decide
to retry, or cancel. This handles the probably most common failure,
which is crashed workers. If you want to handle workers that get into
endless loops but appear to be alive, you would have to add
heartbeating and it all gets more complex. I'd not go there in a first
design.

Trick is to make the simplest possible design you can, break it with
simulated failures, and solve those. The common trap is to over-design
your first architecture.

A reliable pipeline was one of the patterns I'd meant to build but
didn't get around to. Sorry about that.

-Pieter
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] DEALER to ROUTER and reusing identity.

2013-02-25 Thread Pieter Hintjens
On Mon, Feb 25, 2013 at 4:50 PM, Trevor Bernard
trevor.bern...@gmail.com wrote:

 A reliable pipeline was one of the patterns I'd meant to build but
 didn't get around to. Sorry about that.

 I can help you flesh this out.

I'd start by taking the existing pipeline example and adding random
failures to the workers. Then, add the control message that lets the
sink detect a failure.

-Pieter
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] DEALER to ROUTER and reusing identity.

2013-02-24 Thread Min
Hi,

Please try using ROUTER_MANDATORY at router socket. If you get EHOSTUNREACH
at send, you should retry send.

Thanks
Min

2013년 2월 25일 월요일에 Trevor Bernard님이 작성:

 Hi,

 I have a use case where I'd like to re-cycle DEALER identities when a
 failover situation occurs. I have one service SV1 that creates a
 DEALER connection to a ROUTER socket on SVn. SV1 has a hot standby and
 uses the same identity in a failover situation. The first connect goes
 as you would expect, but in the situation of a failover, the second
 SV1 never receives any messages from SVn.

 Can someone point me in the right direction on how to route back the
 response?

 -Trev
 ___
 zeromq-dev mailing list
 zeromq-dev@lists.zeromq.org javascript:;
 http://lists.zeromq.org/mailman/listinfo/zeromq-dev

___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] DEALER to ROUTER and reusing identity.

2013-02-24 Thread Trevor Bernard
Hi Min,

Thanks for the suggestion. I added ROUTER_MANDATORY to my ROUTER but
this didn't resolve my original problem however. The problem is after
I reconnect on a different DEALER socket with the same identity, it no
longer correctly routes the response.

I'm curious if there is a way to reuse identities upon disconnects.
I'd rather not send a unique GUID with my payload since I already have
my service information readily available.

-Trev

On Sun, Feb 24, 2013 at 9:27 PM, Min mini...@gmail.com wrote:
 Hi,

 Please try using ROUTER_MANDATORY at router socket. If you get EHOSTUNREACH
 at send, you should retry send.

 Thanks
 Min

 2013년 2월 25일 월요일에 Trevor Bernard님이 작성:

 Hi,

 I have a use case where I'd like to re-cycle DEALER identities when a
 failover situation occurs. I have one service SV1 that creates a
 DEALER connection to a ROUTER socket on SVn. SV1 has a hot standby and
 uses the same identity in a failover situation. The first connect goes
 as you would expect, but in the situation of a failover, the second
 SV1 never receives any messages from SVn.

 Can someone point me in the right direction on how to route back the
 response?

 -Trev
 ___
 zeromq-dev mailing list
 zeromq-dev@lists.zeromq.org
 http://lists.zeromq.org/mailman/listinfo/zeromq-dev


 ___
 zeromq-dev mailing list
 zeromq-dev@lists.zeromq.org
 http://lists.zeromq.org/mailman/listinfo/zeromq-dev

___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] DEALER to ROUTER and reusing identity.

2013-02-24 Thread Pieter Hintjens
On Mon, Feb 25, 2013 at 1:53 AM, Trevor Bernard
trevor.bern...@gmail.com wrote:

 I have a use case where I'd like to re-cycle DEALER identities when a
 failover situation occurs. I have one service SV1 that creates a
 DEALER connection to a ROUTER socket on SVn. SV1 has a hot standby and
 uses the same identity in a failover situation. The first connect goes
 as you would expect, but in the situation of a failover, the second
 SV1 never receives any messages from SVn.

I'd advise against trying to use identities to make this failover
work. You're going to be fighting 0MQ's autoreconnect. Instead,
provide authentication in the protocol itself and design the router
app to do the failover itself.

-Pieter
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev