Return-Path: X-Original-To: apmail-zookeeper-user-archive@www.apache.org Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C7687DAB4 for ; Fri, 28 Sep 2012 00:07:37 +0000 (UTC) Received: (qmail 97532 invoked by uid 500); 28 Sep 2012 00:07:36 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 97462 invoked by uid 500); 28 Sep 2012 00:07:36 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 97256 invoked by uid 500); 28 Sep 2012 00:07:36 -0000 Delivered-To: apmail-hadoop-zookeeper-user@hadoop.apache.org Received: (qmail 97218 invoked by uid 99); 28 Sep 2012 00:07:36 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2012 00:07:36 +0000 Received: from localhost (HELO mail-pb0-f48.google.com) (127.0.0.1) (smtp-auth username phunt, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2012 00:07:35 +0000 Received: by pbcwy7 with SMTP id wy7so3778339pbc.35 for ; Thu, 27 Sep 2012 17:07:35 -0700 (PDT) Received: by 10.66.76.165 with SMTP id l5mr13106527paw.79.1348790855449; Thu, 27 Sep 2012 17:07:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.163.34 with HTTP; Thu, 27 Sep 2012 17:07:15 -0700 (PDT) In-Reply-To: References: <5064B85B.1040801@demandware.com> From: Patrick Hunt Date: Thu, 27 Sep 2012 17:07:15 -0700 Message-ID: Subject: Re: Zookeeper delay to reconnect To: user@zookeeper.apache.org Cc: michi@cs.stanford.edu, zookeeper-user@hadoop.apache.org Content-Type: text/plain; charset=ISO-8859-1 Hi Brian, well, in my proposal the default would be the current behavior. With the discretion of the zk operator to change, so it shouldn't be any worse. You've piqued my interest - a single client attempting to connect is responsible for bringing down the entire cluster? Could you provide more details? Patrick On Thu, Sep 27, 2012 at 4:58 PM, Brian Tarbox wrote: > I would lobby not to change this...I'm still occasionally dealing with > clients spinning trying to connect...which brings down the whole cluster > until that one client is killed. > > Brian > > On Thu, Sep 27, 2012 at 7:55 PM, Patrick Hunt wrote: > >> The random sleep was explicitly added to reduce herd effects and >> general "spinning client" problems iirc. Keep in mind that ZK >> generally trades of performance for availability. It wouldn't be a >> good idea to remove it in general. If anything we should have a more >> aggressive backoff policy in the case where clients are just spinning. >> >> Perhaps a plug-able approach here? Where the default is something like >> what we already have, but allow users to implement their own policy if >> they like. We could have a few implementations "out of the box"; 1) >> current, 2) no wait, 3) exponential backoff after trying each server >> in the ensemble, etc... This would also allow for experimentation. >> >> Patrick >> >> On Thu, Sep 27, 2012 at 2:28 PM, Michi Mutsuzaki >> wrote: >> > Hi Sergei, >> > >> > Your suggestion sounds reasonable to me. I think the sleep was added >> > so that the client doesn't spin when the entire zookeeper is down. The >> > client could try to connect to each server without sleep, and sleep >> > for 1 second only after failing to connect to all the servers in the >> > cluster. >> > >> > Thanks! >> > --Michi >> > >> > On Thu, Sep 27, 2012 at 1:34 PM, Sergei Babovich >> > wrote: >> >> Hi, >> >> Zookeeper implements a delay of up to 1 second before trying to >> reconnect. >> >> >> >> ClientCnxn$SendThread >> >> @Override >> >> public void run() { >> >> ... >> >> while (state.isAlive()) { >> >> try { >> >> if (!clientCnxnSocket.isConnected()) { >> >> if(!isFirstConnect){ >> >> try { >> >> Thread.sleep(r.nextInt(1000)); >> >> } catch (InterruptedException e) { >> >> LOG.warn("Unexpected exception", e); >> >> } >> >> >> >> This creates "outages" (even with simple retry on ConnectionLoss) up to >> 1s >> >> even with perfectly healthy cluster like in scenario of rolling >> restart. In >> >> our scenario it might be a problem under high load creating a spike in a >> >> number of requests waiting on zk operation. >> >> Would it be a better strategy to perform reconnect attempt immediately >> at >> >> least one time? Or there is more to it? >> > > > > -- > http://about.me/BrianTarbox