Return-Path: Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: (qmail 71728 invoked from network); 10 Mar 2011 21:43:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Mar 2011 21:43:03 -0000 Received: (qmail 51427 invoked by uid 500); 10 Mar 2011 21:43:03 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 51400 invoked by uid 500); 10 Mar 2011 21:43:03 -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 51392 invoked by uid 99); 10 Mar 2011 21:43:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Mar 2011 21:43:03 +0000 X-ASF-Spam-Status: No, hits=4.0 required=5.0 tests=FREEMAIL_FROM,FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ishaaq@gmail.com designates 209.85.161.42 as permitted sender) Received: from [209.85.161.42] (HELO mail-fx0-f42.google.com) (209.85.161.42) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Mar 2011 21:42:57 +0000 Received: by fxm1 with SMTP id 1so524466fxm.15 for ; Thu, 10 Mar 2011 13:42:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=FqX4bh0nnbeGTpE3UuB+GAJO3hcmcDeVgLA+fdS31Jk=; b=NLkeXUFAx2O1u6cxuSJw2dyT9jfFT0QDcAZ7DmO3f2zV5msZPN4XDqjxoOHJwck3nl xTDrWnlZHWx7j+rfCAmNzDUlOJhL7CXZZZH6eP6nyMt6hH1VkOAd9Pal8EepCDqCCZ7W rtX62irDxDyCC5oLouiPl41sH5wbEUKXUaTT8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=gdra8X0VlCiqO4fikFuzlSDb7k/3aJomr3xtV2ZcTpCzP+1Zv7Vk7gWnei3kXgxJKE K3qfuxxl+Lzx0mCvbszR4pEKTBP5hRYt1jak181BUxPZJkhdxKWpe4jcOCl8dPk1U7lc o+ZQ+gi3ITEytTtqknNhdeg7MERFshTj9OSD0= MIME-Version: 1.0 Received: by 10.223.77.16 with SMTP id e16mr1219074fak.87.1299793353119; Thu, 10 Mar 2011 13:42:33 -0800 (PST) Received: by 10.223.96.206 with HTTP; Thu, 10 Mar 2011 13:42:33 -0800 (PST) In-Reply-To: References: <24DE9291-603F-4F67-9A88-7363E8A125BA@gmail.com> Date: Fri, 11 Mar 2011 08:42:33 +1100 Message-ID: Subject: Re: Question about sharing Zookeeper connections From: Ishaaq Chandy To: user@zookeeper.apache.org Cc: Ted Dunning Content-Type: multipart/alternative; boundary=001517448a7a181c8f049e27b9e0 --001517448a7a181c8f049e27b9e0 Content-Type: text/plain; charset=ISO-8859-1 Sorry to resurrect an old discussion, but this is pertinent to me. So, just to clarify, what you're saying is - if you've got a subsystem in an app that uses ZK then you should be fine (i.e both from a thread-safety perspective as well as a performance perspective) sharing a single connection between all the threads running code in that subsystem (this is what I interpreted your phrase "kind of use" to mean) - even if, say, you expect thousands of calls to happen on that one connection over the span of, say, a couple of minutes? On the other hand are you also saying that it is advisable to have separate ZK connections for each subystem that requires it? Even if they are all running in the same JVM? Ishaaq On 19 February 2011 06:40, Ted Dunning wrote: > Most applications just share a single connection for all uses of a single > class. That might be viewed at the logically simplest extreme of a simple > connection pool. > > Why did you need more than one connection for each kind of use? > > On Fri, Feb 18, 2011 at 11:13 AM, Peco Karayanev >wrote: > > > Hi, > > I slightly disagree with the priority for a "connection pool" for > > zookeeper. > > I had to implement a connection pool/reuse for a smaller environment > (under > > 50 nodes). I have a toolchain that can be composed of parts, and each > part > > needed some synchronization through zookeeper. So even on a smaller > system > > these heavier toolchains started using a lot of physical sessions and > > connections. Hence the connection pool. Also from performance perspective > > establishing a TCP connection for every session adds latency overhead. > > > > Cheers > > Peco > > > > > > On Fri, Feb 18, 2011 at 11:58 AM, Benjamin Reed > > wrote: > > > > > it does seem like a good idea to make multiple zk handles share a > > > connection, but as ted points out, they may have different timeouts, > > which > > > would make the sharing logic quite complicated. i think the > > implementation > > > might also be quite complicated. having said that, if someone could > come > > up > > > with a simple and correct connection sharing implementation, we (or at > > > least > > > i) would be open to it. > > > > > > ben > > > > > > On Fri, Feb 18, 2011 at 9:31 AM, Ted Dunning > > > wrote: > > > > > > > On Fri, Feb 18, 2011 at 1:24 AM, YUNG-LIN HO > > wrote: > > > > > > > > > Because zookeeper clients will try to keep session alive by sending > a > > > > ping > > > > > request every 2 seconds. If libraries in an application do not > share > > > > > connections with each other, they would flood the zookeeper server > > with > > > > > unnecessary requests and drag down performance of the server. > > > > > > > > > > > > > Make sure that you have a valid reason to worry first. > > > > > > > > Do you have thousands of clients? > > > > > > > > If not, these keep-alives are likely to be undetectable, load-wise. > > > > > > > > > > > > > I am wondering is there any connection manager exists in the > > > > > Hadoop/Zookeeper project that helps users to share connections? > > > > > > > > > > > > > Yes. Zookeeper. > > > > > > > > Just open a single connection and pass it around via a singleton of > > some > > > > kind or your favorite dependency injection technique. > > > > > > > > This isn't always a great idea since your disconnect and expiration > > > > strategies might differ between different uses in important ways. > > > > > > > > > > --001517448a7a181c8f049e27b9e0--