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 7F73110641 for ; Wed, 31 Jul 2013 23:06:02 +0000 (UTC) Received: (qmail 48683 invoked by uid 500); 31 Jul 2013 23:06:01 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 48653 invoked by uid 500); 31 Jul 2013 23:06:01 -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 48645 invoked by uid 99); 31 Jul 2013 23:06:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Jul 2013 23:06:01 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of henry@cloudera.com designates 209.85.214.174 as permitted sender) Received: from [209.85.214.174] (HELO mail-ob0-f174.google.com) (209.85.214.174) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Jul 2013 23:05:55 +0000 Received: by mail-ob0-f174.google.com with SMTP id wd6so2566294obb.33 for ; Wed, 31 Jul 2013 16:05:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:x-gm-message-state; bh=FyeHVZsoGS72MMyn7gsJvhWDn4JIqzWGFjcootfyjGg=; b=INeyEPYf48jxS47pkljAe2O0m8R6nLOCIEbAXczFIBwb11hoMZsFK8DSaUaBKl80fz PKT84Ls479a6Q00Y03kmW6y74prAFrlAt0lu+zHHAVloQZakvmPrFZW8gfa84NAKTZvQ E1kqzU5lY76aWS/KUiLfCf1VhKlK+PhpYikPnkzvG7afCZ3bpmKp2NphEmIrRUy+KTjD cKiDG/CVeU85f+wSW/cPD6g6D33wd8pofNW+iH3wf22HaEFdohGZjY8V5/qgRoVopdU5 E5ZnNdumBzyMojPl3fcSpwZAkCYdahGpovHEkLuoQu2v8wx1l/3TXVnatfnpbavCFkmq XW/A== X-Received: by 10.182.72.170 with SMTP id e10mr63394403obv.62.1375311934830; Wed, 31 Jul 2013 16:05:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.132.38 with HTTP; Wed, 31 Jul 2013 16:05:14 -0700 (PDT) In-Reply-To: References: From: Henry Robinson Date: Wed, 31 Jul 2013 16:05:14 -0700 Message-ID: Subject: Re: Zookeeper performance To: "user@zookeeper.apache.org" Content-Type: multipart/alternative; boundary=001a11c2f3d854c84304e2d6c381 X-Gm-Message-State: ALoCoQnFiOMTTs79VtJ6egYKqzdylBh5g6gNem5wjUWsx/hhmj0wrjkzwYWztYX8V6m/4Gd2AWX6 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2f3d854c84304e2d6c381 Content-Type: text/plain; charset=ISO-8859-1 So how about the following optimistic approach: 1. Read the current version of the database (stored in a znode's version metadata). If it is even, wait and try again; even numbers mean someone is committing and the DB might be in an inconsistent state. Then read the state from the database your update will rely upon (user1.name, in this instance). You must also be able to atomically read the current version from the database as well as zookeeper, to ensure that the data is from the version you think it is. If the DB version does not match the ZK version, restart. 2. Once an update is ready to commit, test-and-increment the current version in ZK to an even number, write your update to the DB, along with the eventual version of the data (the next odd number). 3. Increment the current version in ZK to an odd number. The even / odd distinction means that you can detect when someone else is updating the database, since otherwise there's no way to do so atomically with an update to ZK (so another transaction can't tell if you've finished your update or not, and so doesn't know when to wait until). The problem is failure - what happens if a client fails while it's writing a transaction? Eventually someone can increment the transaction number, and if you provide an 'undo' log before you make any changes, that client can possibly recover from a partial commit. But at this point you need to understand your application's requirements in much more detail than we do to make recommendations. In particular, your storage layer may offer sufficiently powerful primitives such that you don't need ZK; although if it's a filesystem then that probably isn't true. Henry On 31 July 2013 15:51, Baskar Duraikannu wrote: > We cannot always resolve conflicts ourselves. For example, let us say that > a) user1 changed the name from 'Kathy' to Katherineb) user2 changes the > name from 'Kathy' to 'Kat' > Both read 'Kathy' as input; user1's update succeeded. If we need to let > user2 know that something has changed as this may result in the user not > changing 'Kathy' to 'Kat' (as an example). > Hope this explains > > > Date: Wed, 31 Jul 2013 07:49:39 -0400 > > Subject: Re: Zookeeper performance > > From: camille@apache.org > > To: user@zookeeper.apache.org > > > > This sounds highly error prone to me regardless of whether or not > zookeeper > > can handle the load-. Why not just use a standard transaction model with > a > > vector clock or other timing device to detect conflicts so you don't have > > to worry about a second server to talk to (zookeeper) to do an update? > > On Jul 31, 2013 7:17 AM, "Baskar Duraikannu" < > baskar.duraikannu@outlook.com> > > wrote: > > > > > Hello > > > > > > We are looking to use zookeeper for optimistic concurrency. Basically > when > > > the user saves data on a screen, we need to lock, read to ensure that > no > > > one else has changed the row while user is editing data, persist data > and > > > unlock znode. > > > > > > If the app/thread does not get a lock, we may set a watch so that > polling > > > is avoided. > > > > > > Our application is write intensive certain times of the day. We may get > > > about 100k requests per second. Can zookeeper handle this volume? > > -- Henry Robinson Software Engineer Cloudera 415-994-6679 --001a11c2f3d854c84304e2d6c381--