Return-Path: Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: (qmail 42666 invoked from network); 2 Dec 2010 15:48:02 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Dec 2010 15:48:02 -0000 Received: (qmail 17930 invoked by uid 500); 2 Dec 2010 15:48:02 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 17647 invoked by uid 500); 2 Dec 2010 15:48:00 -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 17639 invoked by uid 99); 2 Dec 2010 15:47:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Dec 2010 15:47:59 +0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=FREEMAIL_FROM,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 ted.dunning@gmail.com designates 74.125.82.46 as permitted sender) Received: from [74.125.82.46] (HELO mail-ww0-f46.google.com) (74.125.82.46) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Dec 2010 15:47:55 +0000 Received: by wwj40 with SMTP id 40so1747489wwj.15 for ; Thu, 02 Dec 2010 07:47:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=JxJI58a9VzKZ7JqBsgRIMOXtDp9rlzJc6o9C6ZKyKeM=; b=L4HTNZNaDe4FT5+CMPk1ua9m4x2kQhZy7pcsf3Yp65IOwl0cI0VyRXLQHY252k5/mp 5ia0niSMFVBjXBq7MaCsAr3LG41iQa+Ch/NtxvqcNMIctgh5zS4aWBx3wkrktax6FX65 X0tmKSF+AyutMnywq996432TcJYopmt7rIWuY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=aAkqQ0HEOF8BixElz9Ma/aqh9lDFGkqRvOsvakDmg8hw5qVKfS5fK8x2clgMYs9SED iHsquhLdsFVZuhiOQQcxXUbP9EMCVWdb6rM6vyjm1s5c7ARoZcYFMARnCpsAhaPY390W TRY7NusW9ytYMkPh46MgK7RzCesErCCTr+szg= Received: by 10.216.27.77 with SMTP id d55mr344882wea.19.1291304853155; Thu, 02 Dec 2010 07:47:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.158.68 with HTTP; Thu, 2 Dec 2010 07:47:12 -0800 (PST) In-Reply-To: <4CF7BDF5.60905@tis.bz.it> References: <4CF7AD46.9040309@tis.bz.it> <4CF7BDF5.60905@tis.bz.it> From: Ted Dunning Date: Thu, 2 Dec 2010 07:47:12 -0800 Message-ID: Subject: Re: counter with zookeeper To: user@zookeeper.apache.org Content-Type: multipart/alternative; boundary=0016e6dbdeaf11b0b304966f5736 --0016e6dbdeaf11b0b304966f5736 Content-Type: text/plain; charset=UTF-8 I would recommend that you increment the counter by 100 or 1000 and then increment a local counter over the implied range. This will drive the amortized ZK overhead down to tens of microseconds which should be good for almost any application. Your final ids will still be almost entirely contiguous. You could implement a fancier counter in ZK that remembers returned chunks for re-use to get perfect contiguity if you really wanted that. Most dictionary applications can handle some gaps, though. On Thu, Dec 2, 2010 at 7:40 AM, Claudio Martella wrote: > Hi Sam, > > Thank you very much for the reference, I'll implement my code based on > your ZkClock. > > On 12/2/10 4:25 PM, Sam Tunnicliffe wrote: > > Hi Claudio, > > > > we have a very similar use case, and developed > http://github.com/talis/h1 to > > meet it. Initially, we coded up the simplest thing we thought could work > and > > deployed it, figuring that we'd have plenty of scope for improvement once > we > > saw it running with real load. However, to date its been ticking over so > > well we've not really had cause to spend any further effort on it. HTTP > > obviously adds an overhead, but to be honest, latency has not been a > problem > > for us and we typically see response times of a few ms. Contention over > keys > > is not particularly high in our application, so we've not had problems > there > > either. > > > > Cheers, > > > > Sam > > > > Sam Tunnicliffe > > Head of Development, Platform Division > > Talis Systems Ltd > > http://www.talis.com > > > > On 2 December 2010 14:29, Claudio Martella >wrote: > > > >> Hi, > >> > >> I'm trying to implement a String->Long dictionary, as I'm doing text > >> processing in M/R and would like to speed up my things. > >> In order to implement the mapping, I need to access a high speed atomic > >> counter that allows me to pick the latest used Long, increment it and > >> use it for the latest-discovered new word to put in the dictionary. > >> > >> At first i thought about using a regular sequential znode and use the > >> sequence number as the counter value, but I realize the sequence number > >> is an int, while i'd like a long. Is that correct? I'm refering to > >> Stat.getVersion() in the API. > >> > >> In case this strategy is unfeasible, the second possibility is to use a > >> WriteLock to "/counter" to control access the payload of the znode, > >> where i'd put the counter value, or access to a special row in > >> cassandra, where i'd put the counter value. The Cassandra option is > >> probably the best possibility, as i'm storing my dictionary there > >> anyway, but I'd like to hear from you about latency and performance for > >> this options in ZK. > >> > >> > >> Thanks > >> > >> Claudio > >> > >> -- > >> Claudio Martella > >> Digital Technologies > >> Unit Research & Development - Analyst > >> > >> TIS innovation park > >> Via Siemens 19 | Siemensstr. 19 > >> 39100 Bolzano | 39100 Bozen > >> Tel. +39 0471 068 123 > >> Fax +39 0471 068 129 > >> claudio.martella@tis.bz.it http://www.tis.bz.it > >> > >> Short information regarding use of personal data. According to Section > 13 > >> of Italian Legislative Decree no. 196 of 30 June 2003, we inform you > that we > >> process your personal data in order to fulfil contractual and fiscal > >> obligations and also to send you information regarding our services and > >> events. Your personal data are processed with and without electronic > means > >> and by respecting data subjects' rights, fundamental freedoms and > dignity, > >> particularly with regard to confidentiality, personal identity and the > right > >> to personal data protection. At any time and without formalities you can > >> write an e-mail to privacy@tis.bz.it in order to object the processing > of > >> your personal data for the purpose of sending advertising materials and > also > >> to exercise the right to access personal data and other rights referred > to > >> in Section 7 of Decree 196/2003. The data controller is TIS Techno > >> Innovation Alto Adige, Siemens Street n. 19, Bolzano. You can find the > >> complete information on the web site www.tis.bz.it. > >> > >> > >> > > > -- > Claudio Martella > Digital Technologies > Unit Research & Development - Analyst > > TIS innovation park > Via Siemens 19 | Siemensstr. 19 > 39100 Bolzano | 39100 Bozen > Tel. +39 0471 068 123 > Fax +39 0471 068 129 > claudio.martella@tis.bz.it http://www.tis.bz.it > > Short information regarding use of personal data. According to Section 13 > of Italian Legislative Decree no. 196 of 30 June 2003, we inform you that we > process your personal data in order to fulfil contractual and fiscal > obligations and also to send you information regarding our services and > events. Your personal data are processed with and without electronic means > and by respecting data subjects' rights, fundamental freedoms and dignity, > particularly with regard to confidentiality, personal identity and the right > to personal data protection. At any time and without formalities you can > write an e-mail to privacy@tis.bz.it in order to object the processing of > your personal data for the purpose of sending advertising materials and also > to exercise the right to access personal data and other rights referred to > in Section 7 of Decree 196/2003. The data controller is TIS Techno > Innovation Alto Adige, Siemens Street n. 19, Bolzano. You can find the > complete information on the web site www.tis.bz.it. > > > --0016e6dbdeaf11b0b304966f5736--