Return-Path: Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: (qmail 95229 invoked from network); 2 Dec 2010 17:21:54 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Dec 2010 17:21:54 -0000 Received: (qmail 67764 invoked by uid 500); 2 Dec 2010 17:21:54 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 67595 invoked by uid 500); 2 Dec 2010 17:21:53 -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 67586 invoked by uid 99); 2 Dec 2010 17:21:53 -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 17:21:53 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.97.132.207] (HELO homiemail-a5.g.dreamhost.com) (208.97.132.207) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Dec 2010 17:21:47 +0000 Received: from homiemail-a5.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a5.g.dreamhost.com (Postfix) with ESMTP id 7847F704078 for ; Thu, 2 Dec 2010 09:21:26 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=darose.net; h=message-id:date :from:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; q=dns; s=darose.net; b= MLsUfVf8m3EnbctHT06rkhGgBPCIjJbWTvYfipzos4pY6fepUoSS5FU0ygiOvTv6 WMdy0YPe2ZjwOhTAphbtyJ6s6XUm/1xUoCkZFeV/YftjGrI4fwLn6VtPYvh+WFtb B9M8bCcMobBWenCMiEuzV4dhOl7DdAgCod8fRNoQ8D8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=darose.net; h=message-id :date:from:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; s=darose.net; bh=F67DDS tOSBppn1GhtjwGwcpg/NA=; b=sqiEAs8hl9pN8TfU4GA8zDzSEBEunqMLwmqctj GeLDeowSivor2rL3fSY4Z5q9WGG4hqiw3viIEV8aSNrMS6FHdVmRazSLwluEXYc/ ZNrStq4yDj0KgPGZTe6aMwu0Rxjeano3VX57asqaraPDpKOf0pO2sD2Gyso3Gk3s ACoiA= Received: from darsys12 (cpe-66-108-142-190.nyc.res.rr.com [66.108.142.190]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: darose@darose.net) by homiemail-a5.g.dreamhost.com (Postfix) with ESMTPSA id 2621270406F for ; Thu, 2 Dec 2010 09:21:26 -0800 (PST) Received: from [10.1.0.2] by darsys12 with esmtp (Exim 4.72) (envelope-from ) id 1POCqS-0000cx-TT for user@zookeeper.apache.org; Thu, 02 Dec 2010 12:21:24 -0500 Message-ID: <4CF7D594.7000206@darose.net> Date: Thu, 02 Dec 2010 12:21:24 -0500 From: David Rosenstrauch User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101028 Lanikai/3.1.6 MIME-Version: 1.0 To: user@zookeeper.apache.org Subject: Re: counter with zookeeper References: <4CF7AD46.9040309@tis.bz.it> <4CF7BDF5.60905@tis.bz.it> <4CF7C163.7020300@darose.net> <4CF7C243.3060305@tis.bz.it> In-Reply-To: <4CF7C243.3060305@tis.bz.it> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit I don't, for several reasons: a) We request ID's frequently enough that old ones do eventually get used up. b) Even with a largely fragmented ID space, the largest we've seen the bytes contents of that ZK node get up to is 5-6KBytes. So no real worries about either storage space or network I/O when reading/writing to/from the ZK node. DR On 12/02/2010 10:58 AM, Claudio Martella wrote: > I like Ted's idea too. > > David, how do you handle re-compaction of your fragmented ID space? > > > On 12/2/10 4:55 PM, David Rosenstrauch wrote: >> On 12/02/2010 10:47 AM, Ted Dunning wrote: >>> 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. >> >> This is what our library does. You request chunks of, say, 1000 ID's, >> and then push back any remaining unused ID's in the chunk you took. >> >> DR