Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E2ED6200B58 for ; Wed, 27 Jul 2016 22:56:13 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E1E90160A90; Wed, 27 Jul 2016 20:56:13 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 13213160A6F for ; Wed, 27 Jul 2016 22:56:12 +0200 (CEST) Received: (qmail 98603 invoked by uid 500); 27 Jul 2016 20:56:12 -0000 Mailing-List: contact dev-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list dev@ignite.apache.org Received: (qmail 98591 invoked by uid 99); 27 Jul 2016 20:56:11 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jul 2016 20:56:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 86EEF1A0728 for ; Wed, 27 Jul 2016 20:56:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.179 X-Spam-Level: ** X-Spam-Status: No, score=2.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, KAM_LIVE=1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id mvyf6IfWzt3e for ; Wed, 27 Jul 2016 20:56:07 +0000 (UTC) Received: from mail-vk0-f54.google.com (mail-vk0-f54.google.com [209.85.213.54]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id CC8B760E21 for ; Wed, 27 Jul 2016 20:56:06 +0000 (UTC) Received: by mail-vk0-f54.google.com with SMTP id n129so18132918vke.3 for ; Wed, 27 Jul 2016 13:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=cZm4ya0AfRZfmbM0VT0AGINhpJphGXgI547rsXhdpS4=; b=VgbdsqNfjZaMKK1mHKp7DPCiVauQW2cS5CTlPzTGdZPMOVU3VN7pd3VU1aj6sLaSev SfhQGaxSRvGaRvuL7cQ1b1ULyPkxWaCTxpjpis1VFV+O6WUZNf3aEZsbuve+q11zyLi/ +ObvWBmj+xTZIjFXLXiSjjuOFhtKvyDtn1AIqxBY7SySqQpDHpUOk4OObtV1dcsCFZKz V+pd6jrC1bNz+MlYLOclHGjqDBfowvwcFkdUknZ+K10St5bQ486ewi+wPOCXSyg/sJ+i 4G48Y9PO5FSeguSTMhU56RMSw6aUfMmihd95SbU4UZ/YYj+8Xluo4pGJMt4ogpefgwfN QdTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cZm4ya0AfRZfmbM0VT0AGINhpJphGXgI547rsXhdpS4=; b=QYNT/TZqKpQEkhi1Srbuq+ldKYyoTyvKdurXZPBKMuFD0J5VFZMGZLxfGF7nONtyYS VnUylUYzlzVghI9cX0RryqgI6x04lgKMxs8/nTukPMmHnJH0UO/ls8b3l8I/6aTRXzMX mQ+HYXKo+WhPxfhzxPNmLyVMuDmodlREUEQ34xizeRvtR4niyA9NKXc5+BNncwBIN7r5 dODe3poK7uepqk4py3b3p2sX6Gguw1A1cQzhwz2T19aiyu53x3Y6V+GsnADTKs+6o4/v h6FDJyZEuzgnLa4Fj3libohl13Tl9OiKp+Z7PwvIDA2ygNm+Xn50EtpciUqgexwH9MHI ErLA== X-Gm-Message-State: AEkoouvZnc8ye4KsPCCKPjigj1+EOG1peR6BFwIgXcVXRYnhyDR7H2vi6QJUplFfmg6RPr23516YZOnOE+AVwQ== X-Received: by 10.31.67.146 with SMTP id q140mr11883800vka.52.1469652965862; Wed, 27 Jul 2016 13:56:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.126.7 with HTTP; Wed, 27 Jul 2016 13:55:46 -0700 (PDT) In-Reply-To: References: From: Igor Rudyak Date: Wed, 27 Jul 2016 13:55:46 -0700 Message-ID: Subject: Re: Batch support in Cassandra store To: Luiz Felipe Trevisan Cc: dev@ignite.apache.org Content-Type: multipart/alternative; boundary=001a114d95b6f93aca0538a43ecd archived-at: Wed, 27 Jul 2016 20:56:14 -0000 --001a114d95b6f93aca0538a43ecd Content-Type: text/plain; charset=UTF-8 Hi Luiz, Logged batches is not the solution to achieve atomic view of your Ignite transaction changes in Cassandra. The problem with logged batches(aka atomic) is they guarantees that if any part of the batch succeeds, all of it will, no other transactional enforcement is done at the batch level. For example, there is no batch isolation. Clients are able to read the first updated rows from the batch, while other rows are still being updated on the server (in RDBMS terminology it means *READ-UNCOMMITED* isolation level). Thus Cassandra mean "atomic" in the database sense that if any part of the batch succeeds, all of it will. Probably the best way to archive read atomic isolation for Ignite transaction persisting data into Cassandra, is to implement RAMP transactions (http://www.bailis.org/papers/ramp-sigmod2014.pdf) on top of Cassandra. I may create a ticket for this if community would like it. Igor Rudyak On Wed, Jul 27, 2016 at 12:55 PM, Luiz Felipe Trevisan < luizfelipe.trevisan@gmail.com> wrote: > Hi Igor, > > Does it make sense for you using logged batches to guarantee atomicity in > Cassandra in cases we are doing a cross cache transaction operation? > > Luiz > > -- > Luiz Felipe Trevisan > > On Wed, Jul 27, 2016 at 2:05 AM, Dmitriy Setrakyan > wrote: > >> I am very confused still. Ilya, can you please explain what happens in >> Cassandra if user calls IgniteCache.putAll(...) method? >> >> In Ignite, if putAll(...) is called, Ignite will make the best effort to >> execute the update as a batch, in which case the performance is better. >> What is the analogy in Cassandra? >> >> D. >> >> On Tue, Jul 26, 2016 at 9:16 PM, Igor Rudyak wrote: >> >> > Dmitriy, >> > >> > There is absolutely same approach for all async read/write/delete >> > operations - Cassandra session just provides executeAsync(statement) >> > function >> > for all type of operations. >> > >> > To be more detailed about Cassandra batches, there are actually two >> types >> > of batches: >> > >> > 1) *Logged batch* (aka atomic) - the main purpose of such batches is to >> > keep duplicated data in sync while updating multiple tables, but at the >> > cost of performance. >> > >> > 2) *Unlogged batch* - the only specific case for such batch is when all >> > updates are addressed to only *one* partition key and batch having >> > "*reasonable >> > size*". In a such situation there *could be* performance benefits if you >> > are using Cassandra *TokenAware* load balancing policy. In this >> particular >> > case all the updates will go directly without any additional >> > coordination to the primary node, which is responsible for storing data >> for >> > this partition key. >> > >> > The *generic rule* is that - *individual updates using async mode* >> provides >> > the best performance ( >> > https://docs.datastax.com/en/cql/3.1/cql/cql_using/useBatch.html). >> That's >> > because it spread all updates across the whole cluster. In contrast to >> > this, when you are using batches, what this is actually doing is >> putting a >> > huge amount of pressure on a single coordinator node. This is because >> the >> > coordinator needs to forward each individual insert/update/delete to the >> > correct replicas. In general you're just losing all the benefit of >> > Cassandra TokenAware load balancing policy when you're updating >> different >> > partitions in a single round trip to the database. >> > >> > Probably the only enhancement which could be done is to separate our >> batch >> > to smaller batches, each of which is updating records having the same >> > partition key. In this case it could provide some performance benefits >> when >> > used in combination with Cassandra TokenAware policy. But there are >> several >> > concerns: >> > >> > 1) It looks like rather rare case >> > 2) Makes error handling more complex - you just don't know what >> operations >> > in a batch succeed and what failed and need to retry all batch >> > 3) Retry logic could produce more load on the cluster - in case of >> > individual updates you just need to retry the only mutations which are >> > failed, in case of batches you need to retry the whole batch >> > 4)* Unlogged batch is deprecated in Cassandra 3.0* ( >> > https://docs.datastax.com/en/cql/3.3/cql/cql_reference/batch_r.html), >> > which >> > we are currently using for Ignite Cassandra module. >> > >> > >> > Igor Rudyak >> > >> > >> > >> > On Tue, Jul 26, 2016 at 4:45 PM, Dmitriy Setrakyan < >> dsetrakyan@apache.org> >> > wrote: >> > >> > > >> > > >> > > On Tue, Jul 26, 2016 at 5:53 PM, Igor Rudyak >> wrote: >> > > >> > >> Hi Valentin, >> > >> >> > >> For writeAll/readAll Cassandra cache store implementation uses async >> > >> operations ( >> http://www.datastax.com/dev/blog/java-driver-async-queries) >> > >> and >> > >> futures, which has the best characteristics in terms of performance. >> > >> >> > >> >> > > Thanks, Igor. This link describes the query operations, but I could >> not >> > > find the mention of writes. >> > > >> > > >> > >> Cassandra BATCH statement is actually quite often anti-pattern for >> those >> > >> who come from relational world. BATCH statement concept in Cassandra >> is >> > >> totally different from relational world and is not for optimizing >> > >> batch/bulk operations. The main purpose of Cassandra BATCH is to keep >> > >> denormalized data in sync. For example when you duplicating the same >> > data >> > >> into several tables. All other cases are not recommended for >> Cassandra >> > >> batches: >> > >> - >> > >> >> > >> >> > >> https://medium.com/@foundev/cassandra-batch-loading-without-the-batch-keyword-40f00e35e23e#.k4xfir8ij >> > >> - >> > >> >> > >> >> > >> http://christopher-batey.blogspot.com/2015/02/cassandra-anti-pattern-misuse-of.html >> > >> - >> https://inoio.de/blog/2016/01/13/cassandra-to-batch-or-not-to-batch/ >> > >> >> > >> It's also good to mention that in CassandraCacheStore implementation >> > >> (actually in CassandraSessionImpl) all operation with Cassandra is >> > wrapped >> > >> in a loop. The reason is in a case of failure it will be performed 20 >> > >> attempts to retry the operation with incrementally increasing >> timeouts >> > >> starting from 100ms and specific exception handling logic (Cassandra >> > hosts >> > >> unavailability and etc.). Thus it provides quite reliable persistence >> > >> mechanism. According to load tests, even on heavily overloaded >> Cassandra >> > >> cluster (CPU LOAD > 10 per one core) there were no lost >> > >> writes/reads/deletes and maximum 6 attempts to perform one operation. >> > >> >> > > >> > > I think that the main point about Cassandra batch operations is not >> about >> > > reliability, but about performance. If user batches up 100s of updates >> > in 1 >> > > Cassandra batch, then it will be a lot faster than doing them 1-by-1 >> in >> > > Ignite. Wrapping them into Ignite "putAll(...)" call just seems more >> > > logical to me, no? >> > > >> > > >> > >> >> > >> Igor Rudyak >> > >> >> > >> On Tue, Jul 26, 2016 at 1:58 PM, Valentin Kulichenko < >> > >> valentin.kulichenko@gmail.com> wrote: >> > >> >> > >> > Hi Igor, >> > >> > >> > >> > I noticed that current Cassandra store implementation doesn't >> support >> > >> > batching for writeAll and deleteAll methods, it simply executes all >> > >> updates >> > >> > one by one (asynchronously in parallel). >> > >> > >> > >> > I think it can be useful to provide such support and created a >> ticket >> > >> [1]. >> > >> > Can you please give your input on this? Does it make sense in your >> > >> opinion? >> > >> > >> > >> > [1] https://issues.apache.org/jira/browse/IGNITE-3588 >> > >> > >> > >> > -Val >> > >> > >> > >> >> > > >> > > >> > >> > > --001a114d95b6f93aca0538a43ecd--