SlideShare uma empresa Scribd logo
1 de 19
Investigation of Transactions
in Cassandra
Cassandra Meetup in Tokyo, Fall 2015
December 2, 2015
Ian Chen
Rakuten Inc.
Cassandra usage at Rakuten
•  Cassandra	
  nodes:	
  400+	
  (many	
  clusters)	
  
•  Data	
  size:	
  5B+	
  records	
  
•  Rows	
  accessed/sec:	
  	
  450k+	
  (busiest	
  cluster)	
  
•  Largest	
  cluster:	
  90+	
  nodes	
  
•  Versions:	
  0.8,	
  1.2+,	
  2.0+	
  
•  Community	
  feedback	
  since	
  v0.8	
  
2
New Uses for Cassandra
•  Not	
  just	
  for	
  “big	
  data”	
  
•  Global	
  scale	
  applicaQon	
  data	
  
•  TransacQons	
  and	
  more	
  
3
4
Agenda	
  
	
  Consistency	
  (CAP)	
  1	
  
	
  Atomicity	
  (ACID)	
  2	
  
	
  Isola8on	
  (ACID)	
  3	
  
	
  Example	
  4	
  
5
The	
  “C”	
  is	
  for	
  Consistency	
  
“..	
  any	
  transacQon	
  will	
  bring	
  the	
  database	
  from	
  
one	
  valid	
  state	
  to	
  another.”	
  
“…all	
  clients	
  have	
  the	
  same	
  view	
  of	
  the	
  data.”	
  
CAP	
  Theorem	
  “C”	
  
ACID	
  “C”	
  
Eventually..	
  
6
Tunable	
  Consistency	
  
•  Manage	
  consistency	
  in	
  your	
  applicaQon	
  
•  Decide	
  consistency	
  per	
  transacQon	
  
CONSISTENCY ONE;
UPDATE users SET name='IAN' WHERE name='ian';
CONSISTENCY ALL;
SELECT * FROM users WHERE name='ian';
7
Strong	
  Consistency	
  
*	
  QUORUM	
  =	
  (replicaQon	
  factor	
  /	
  2)	
  +	
  1	
  	
  
nodes	
  	
  
wri_en	
  
nodes	
  	
  
read	
  
replicaQon	
  
factor	
  
R	
  +	
  W	
  >	
  N	
  
Write	
  ONE	
   Read	
  ONE	
   =	
   WEAK	
  
Write	
  ONE	
   Read	
  ALL	
   =	
   STRONG	
  
Write	
  ALL	
   Read	
  ONE	
   =	
   STRONG	
  
Write	
  QUORUM	
   Read	
  QUORUM	
   =	
   STRONG	
  
8
“A”	
  is	
  for	
  Atomicity	
  
START TRANSACTION;
INSERT INTO users (name, country)
VALUES(‘ian’, ‘Australia’);
INSERT INTO users (name, country)
VALUES(‘meg’, ‘Japan’);
COMMIT; // or ROLLBACK
aka	
  transacQon	
  consistency,	
  linearizable	
  consistency,	
  serial	
  isolaQon	
  level	
  
All	
  succeed	
  or	
  none	
  succeed	
  
SQL:	
  
9
Cassandra	
  BATCH	
  
BEGIN BATCH
INSERT INTO users (name, country)
VALUES(‘ian’, ‘Australia’);
INSERT INTO users (name, country)
VALUES(‘meg’, ‘Japan’);
APPLY BATCH;
Guarantees	
  ALL	
  will	
  succeed	
  or	
  ALL	
  will	
  fail	
  
CQL:	
  
10
“I”	
  Is	
  For	
  Isola8on	
  
START TRANSACTION;
SELECT current_caps FROM bottlecaps
WHERE name='ian' FOR UPDATE;
UPDATE bottlecaps
SET current_caps = current_caps + 1;
COMMIT;
Is	
  anyone	
  else	
  changing	
  this	
  data?	
  
SQL:	
  
11
Cassandra	
  Lightweight	
  Transac8ons	
  
INSERT INTO users (name, country)
VALUES(‘ian’, ‘Australia’) IF NOT EXISTS;
UPDATE users SET country=‘Japan’
WHERE name=‘ian’ IF country=‘Australia’;
Allows	
  you	
  to	
  set	
  condiQons	
  of	
  an	
  update	
  
CQL:	
  
12
Op8mis8c	
  vs	
  Pessimis8c	
  Locking	
  
PessimisQc	
  (SQL)	
   OpQmisQc	
  (CQL)	
  
SELECT	
  	
  
FOR	
  UPDATE	
  
SELECT	
  	
  
FOR	
  UPDATE	
  
COMMIT	
  
COMMIT	
  
lock	
  
SELECT	
  
SELECT	
  
UPDATE	
  ..	
  IF	
  …	
  
UPDATE	
  ..	
  IF	
  …	
  
Thread	
  1	
   Thread	
  2	
  
lock	
  
Thread	
  1	
   Thread	
  2	
  
13
PuTng	
  It	
  Together	
  
1.  Record a transaction
2.  Keep track of the total
3.  Ensure they are updated atomically
Example	
  
14
name	
 current_caps tx_id amount balance
ian	
 0	
 tx001	
 null	
 null	
Example: Bottlecaps	
CREATE TABLE bottlecaps (
name text,
current_caps int STATIC,
tx_id int,
amount int,
balance int,
PRIMARY KEY ((name), tx_id)
);
// initialize user
INSERT INTO bottlecaps (name, tx_id, current_caps)
VALUES ('ian', 'tx001', 0);
15
name	
 current_caps tx_id amount balance
ian	
 10	
tx001	
 null	
 null	
tx002	
 10	
 10	
Get Some Caps	
BEGIN BATCH
UPDATE bottlecaps SET current_caps = 10
WHERE name='ian'
IF current_caps = 0;
INSERT INTO bottlecaps (name, tx_id, amount, balance)
VALUES ('ian', 'tx003', 7, 17);
APPLY BATCH;
16
name	
 current_caps tx_id amount balance
ian	
 17	
tx001	
 null	
 null	
tx002	
 10	
 10	
tx003	
 7	
 17	
Get Some More Caps	
BEGIN BATCH
UPDATE bottlecaps SET current_caps = 17
WHERE name='ian'
IF current_caps = 10;
INSERT INTO bottlecaps (name, tx_id, amount, balance)
VALUES ('ian', 'tx003', 7, 17);
APPLY BATCH;
17
name	
 current_caps tx_id amount balance
ian	
 2	
tx001	
 null	
 null	
tx002	
 10	
 10	
tx003	
 7	
 17	
tx004	
 -15	
 2	
Spend 15 Caps	
BEGIN BATCH
UPDATE bottlecaps SET current_caps = 2
WHERE name='ian'
IF current_caps = 17;
INSERT INTO bottlecaps (name, tx_id, amount, balance)
VALUES ('ian', 'tx004', -15, 2);
APPLY BATCH;
18
Summary	
  
Do	
  the	
  work	
  in	
  your	
  applicaQon	
  code.	
  
	
  
1.  Consistency	
  across	
  all	
  nodes	
  
•  Tune	
  Cassandra	
  access	
  to	
  behave	
  with	
  “strong	
  consistency”	
  
	
  
2.  Atomicity	
  of	
  TransacQons	
  
•  Use	
  Cassandra	
  BATCH	
  
3.  IsolaQon	
  of	
  TransacQons	
  
•  Use	
  a	
  Lightweight	
  TransacQon	
  
19
Thanks	
  ☺	
  
	
  
Ian	
  Chen	
  
ian.chen@rakuten.com	
  
@icchanosaur 	
  	
  
	
  

Mais conteúdo relacionado

Mais procurados

Cassandra Summit 2013 Keynote
Cassandra Summit 2013 KeynoteCassandra Summit 2013 Keynote
Cassandra Summit 2013 Keynotejbellis
 
Enable archivelod mode in oracle rac12cR1 with asm location
Enable archivelod mode  in oracle rac12cR1 with asm locationEnable archivelod mode  in oracle rac12cR1 with asm location
Enable archivelod mode in oracle rac12cR1 with asm locationDebasish Nayak
 
Cassandra Community Webinar | Become a Super Modeler
Cassandra Community Webinar | Become a Super ModelerCassandra Community Webinar | Become a Super Modeler
Cassandra Community Webinar | Become a Super ModelerDataStax
 
2018 02-22 React, Redux & Building Applications that Scale | Redux
2018 02-22 React, Redux & Building Applications that Scale | Redux2018 02-22 React, Redux & Building Applications that Scale | Redux
2018 02-22 React, Redux & Building Applications that Scale | ReduxCodifly
 
Bulk Loading Data into Cassandra
Bulk Loading Data into CassandraBulk Loading Data into Cassandra
Bulk Loading Data into CassandraDataStax
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7Dongho Cho
 
LinkRest at JeeConf 2017
LinkRest at JeeConf 2017LinkRest at JeeConf 2017
LinkRest at JeeConf 2017Andrus Adamchik
 
MicroProfile: uma nova forma de desenvolver aplicações corporativas na era do...
MicroProfile: uma nova forma de desenvolver aplicações corporativas na era do...MicroProfile: uma nova forma de desenvolver aplicações corporativas na era do...
MicroProfile: uma nova forma de desenvolver aplicações corporativas na era do...Otávio Santana
 
Buenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationBuenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationMark Proctor
 
Cassandra For Online Systems, What actually works
Cassandra For Online Systems, What actually worksCassandra For Online Systems, What actually works
Cassandra For Online Systems, What actually worksjdsumsion
 
Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataMongoDB
 
Cassandra 2.0 better, faster, stronger
Cassandra 2.0   better, faster, strongerCassandra 2.0   better, faster, stronger
Cassandra 2.0 better, faster, strongerPatrick McFadin
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTDavid Chandler
 
Cassandra EU - Data model on fire
Cassandra EU - Data model on fireCassandra EU - Data model on fire
Cassandra EU - Data model on firePatrick McFadin
 
Dsi 11g convert_to RAC
Dsi 11g convert_to RACDsi 11g convert_to RAC
Dsi 11g convert_to RACAnil Kumar
 

Mais procurados (20)

Cassandra Summit 2013 Keynote
Cassandra Summit 2013 KeynoteCassandra Summit 2013 Keynote
Cassandra Summit 2013 Keynote
 
Enable archivelod mode in oracle rac12cR1 with asm location
Enable archivelod mode  in oracle rac12cR1 with asm locationEnable archivelod mode  in oracle rac12cR1 with asm location
Enable archivelod mode in oracle rac12cR1 with asm location
 
Cassandra Community Webinar | Become a Super Modeler
Cassandra Community Webinar | Become a Super ModelerCassandra Community Webinar | Become a Super Modeler
Cassandra Community Webinar | Become a Super Modeler
 
2018 02-22 React, Redux & Building Applications that Scale | Redux
2018 02-22 React, Redux & Building Applications that Scale | Redux2018 02-22 React, Redux & Building Applications that Scale | Redux
2018 02-22 React, Redux & Building Applications that Scale | Redux
 
Bulk Loading Data into Cassandra
Bulk Loading Data into CassandraBulk Loading Data into Cassandra
Bulk Loading Data into Cassandra
 
Rxjs vienna
Rxjs viennaRxjs vienna
Rxjs vienna
 
Cassandra 2.2 & 3.0
Cassandra 2.2 & 3.0Cassandra 2.2 & 3.0
Cassandra 2.2 & 3.0
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7
 
Drools rule Concepts
Drools rule ConceptsDrools rule Concepts
Drools rule Concepts
 
LinkRest at JeeConf 2017
LinkRest at JeeConf 2017LinkRest at JeeConf 2017
LinkRest at JeeConf 2017
 
MicroProfile: uma nova forma de desenvolver aplicações corporativas na era do...
MicroProfile: uma nova forma de desenvolver aplicações corporativas na era do...MicroProfile: uma nova forma de desenvolver aplicações corporativas na era do...
MicroProfile: uma nova forma de desenvolver aplicações corporativas na era do...
 
Buenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationBuenos Aires Drools Expert Presentation
Buenos Aires Drools Expert Presentation
 
Cassandra For Online Systems, What actually works
Cassandra For Online Systems, What actually worksCassandra For Online Systems, What actually works
Cassandra For Online Systems, What actually works
 
Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your Data
 
Cassandra at BrightTag
Cassandra at BrightTagCassandra at BrightTag
Cassandra at BrightTag
 
Cassandra 2.0 better, faster, stronger
Cassandra 2.0   better, faster, strongerCassandra 2.0   better, faster, stronger
Cassandra 2.0 better, faster, stronger
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWT
 
Cassandra EU - Data model on fire
Cassandra EU - Data model on fireCassandra EU - Data model on fire
Cassandra EU - Data model on fire
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
 
Dsi 11g convert_to RAC
Dsi 11g convert_to RACDsi 11g convert_to RAC
Dsi 11g convert_to RAC
 

Semelhante a Investigation of Transactions in Cassandra

Cassandra summit keynote 2014
Cassandra summit keynote 2014Cassandra summit keynote 2014
Cassandra summit keynote 2014jbellis
 
Use this script for the assignment.Please follow instructions as t.docx
Use this script for the assignment.Please follow instructions as t.docxUse this script for the assignment.Please follow instructions as t.docx
Use this script for the assignment.Please follow instructions as t.docxgarnerangelika
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
Managing Cassandra at Scale by Al Tobey
Managing Cassandra at Scale by Al TobeyManaging Cassandra at Scale by Al Tobey
Managing Cassandra at Scale by Al TobeyDataStax Academy
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to CassandraGokhan Atil
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data PipelinesHostedbyConfluent
 
Time series with Apache Cassandra - Long version
Time series with Apache Cassandra - Long versionTime series with Apache Cassandra - Long version
Time series with Apache Cassandra - Long versionPatrick McFadin
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
Cassandra Tutorial
Cassandra TutorialCassandra Tutorial
Cassandra Tutorialmubarakss
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
Cassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra ApplicationsCassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra ApplicationsChristopher Batey
 
Apache Cassandra 2.0
Apache Cassandra 2.0Apache Cassandra 2.0
Apache Cassandra 2.0Joe Stein
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for CassandraEdward Capriolo
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"DataStax Academy
 
DataStax NYC Java Meetup: Cassandra with Java
DataStax NYC Java Meetup: Cassandra with JavaDataStax NYC Java Meetup: Cassandra with Java
DataStax NYC Java Meetup: Cassandra with Javacarolinedatastax
 

Semelhante a Investigation of Transactions in Cassandra (20)

Cassandra summit keynote 2014
Cassandra summit keynote 2014Cassandra summit keynote 2014
Cassandra summit keynote 2014
 
Use this script for the assignment.Please follow instructions as t.docx
Use this script for the assignment.Please follow instructions as t.docxUse this script for the assignment.Please follow instructions as t.docx
Use this script for the assignment.Please follow instructions as t.docx
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
 
Managing Cassandra at Scale by Al Tobey
Managing Cassandra at Scale by Al TobeyManaging Cassandra at Scale by Al Tobey
Managing Cassandra at Scale by Al Tobey
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data Pipelines
 
Time series with Apache Cassandra - Long version
Time series with Apache Cassandra - Long versionTime series with Apache Cassandra - Long version
Time series with Apache Cassandra - Long version
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
Cassandra Tutorial
Cassandra TutorialCassandra Tutorial
Cassandra Tutorial
 
Ch6
Ch6Ch6
Ch6
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Cassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra ApplicationsCassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra Applications
 
Apache Cassandra 2.0
Apache Cassandra 2.0Apache Cassandra 2.0
Apache Cassandra 2.0
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
 
DataStax NYC Java Meetup: Cassandra with Java
DataStax NYC Java Meetup: Cassandra with JavaDataStax NYC Java Meetup: Cassandra with Java
DataStax NYC Java Meetup: Cassandra with Java
 

Mais de datastaxjp

Db tech showcase 2016
Db tech showcase 2016Db tech showcase 2016
Db tech showcase 2016datastaxjp
 
Cassandra Meetup Tokyo, 2016 Spring
Cassandra Meetup Tokyo, 2016 SpringCassandra Meetup Tokyo, 2016 Spring
Cassandra Meetup Tokyo, 2016 Springdatastaxjp
 
Cassandra Meetup Tokyo, 2016 Spring 2
Cassandra Meetup Tokyo, 2016 Spring 2Cassandra Meetup Tokyo, 2016 Spring 2
Cassandra Meetup Tokyo, 2016 Spring 2datastaxjp
 
検索エンジンPatheeがAzureとCassandraをどう利用しているのか
検索エンジンPatheeがAzureとCassandraをどう利用しているのか検索エンジンPatheeがAzureとCassandraをどう利用しているのか
検索エンジンPatheeがAzureとCassandraをどう利用しているのかdatastaxjp
 
(LT)Spark and Cassandra
(LT)Spark and Cassandra(LT)Spark and Cassandra
(LT)Spark and Cassandradatastaxjp
 
SparkとCassandraの美味しい関係
SparkとCassandraの美味しい関係SparkとCassandraの美味しい関係
SparkとCassandraの美味しい関係datastaxjp
 
Cassandra summit 2015 レポート
Cassandra summit 2015 レポートCassandra summit 2015 レポート
Cassandra summit 2015 レポートdatastaxjp
 
Cassandra Meetup Tokyo, 2015 Summer
Cassandra Meetup Tokyo, 2015 SummerCassandra Meetup Tokyo, 2015 Summer
Cassandra Meetup Tokyo, 2015 Summerdatastaxjp
 
Cassandra and Spark
Cassandra and Spark Cassandra and Spark
Cassandra and Spark datastaxjp
 
[Cassandra summit Tokyo, 2015] Apache Cassandra日本人コミッターが伝える、"Apache Cassandra...
[Cassandra summit Tokyo, 2015] Apache Cassandra日本人コミッターが伝える、"Apache Cassandra...[Cassandra summit Tokyo, 2015] Apache Cassandra日本人コミッターが伝える、"Apache Cassandra...
[Cassandra summit Tokyo, 2015] Apache Cassandra日本人コミッターが伝える、"Apache Cassandra...datastaxjp
 
[Cassandra summit Tokyo, 2015] Cassandra 2015 最新情報 by ジョナサン・エリス(Jonathan Ellis)
[Cassandra summit Tokyo, 2015] Cassandra 2015 最新情報 by ジョナサン・エリス(Jonathan Ellis)[Cassandra summit Tokyo, 2015] Cassandra 2015 最新情報 by ジョナサン・エリス(Jonathan Ellis)
[Cassandra summit Tokyo, 2015] Cassandra 2015 最新情報 by ジョナサン・エリス(Jonathan Ellis)datastaxjp
 
[db tech showcase Tokyo 2015] E35: Web, IoT, モバイル時代のデータベース、Apache Cassandraを学ぼう
[db tech showcase Tokyo 2015] E35: Web, IoT, モバイル時代のデータベース、Apache Cassandraを学ぼう[db tech showcase Tokyo 2015] E35: Web, IoT, モバイル時代のデータベース、Apache Cassandraを学ぼう
[db tech showcase Tokyo 2015] E35: Web, IoT, モバイル時代のデータベース、Apache Cassandraを学ぼうdatastaxjp
 
[db tech showcase Tokyo 2015] A27: RDBエンジニアの為のNOSQL, 今どうしてNOSQLなのか?
[db tech showcase Tokyo 2015] A27: RDBエンジニアの為のNOSQL, 今どうしてNOSQLなのか?[db tech showcase Tokyo 2015] A27: RDBエンジニアの為のNOSQL, 今どうしてNOSQLなのか?
[db tech showcase Tokyo 2015] A27: RDBエンジニアの為のNOSQL, 今どうしてNOSQLなのか?datastaxjp
 

Mais de datastaxjp (13)

Db tech showcase 2016
Db tech showcase 2016Db tech showcase 2016
Db tech showcase 2016
 
Cassandra Meetup Tokyo, 2016 Spring
Cassandra Meetup Tokyo, 2016 SpringCassandra Meetup Tokyo, 2016 Spring
Cassandra Meetup Tokyo, 2016 Spring
 
Cassandra Meetup Tokyo, 2016 Spring 2
Cassandra Meetup Tokyo, 2016 Spring 2Cassandra Meetup Tokyo, 2016 Spring 2
Cassandra Meetup Tokyo, 2016 Spring 2
 
検索エンジンPatheeがAzureとCassandraをどう利用しているのか
検索エンジンPatheeがAzureとCassandraをどう利用しているのか検索エンジンPatheeがAzureとCassandraをどう利用しているのか
検索エンジンPatheeがAzureとCassandraをどう利用しているのか
 
(LT)Spark and Cassandra
(LT)Spark and Cassandra(LT)Spark and Cassandra
(LT)Spark and Cassandra
 
SparkとCassandraの美味しい関係
SparkとCassandraの美味しい関係SparkとCassandraの美味しい関係
SparkとCassandraの美味しい関係
 
Cassandra summit 2015 レポート
Cassandra summit 2015 レポートCassandra summit 2015 レポート
Cassandra summit 2015 レポート
 
Cassandra Meetup Tokyo, 2015 Summer
Cassandra Meetup Tokyo, 2015 SummerCassandra Meetup Tokyo, 2015 Summer
Cassandra Meetup Tokyo, 2015 Summer
 
Cassandra and Spark
Cassandra and Spark Cassandra and Spark
Cassandra and Spark
 
[Cassandra summit Tokyo, 2015] Apache Cassandra日本人コミッターが伝える、"Apache Cassandra...
[Cassandra summit Tokyo, 2015] Apache Cassandra日本人コミッターが伝える、"Apache Cassandra...[Cassandra summit Tokyo, 2015] Apache Cassandra日本人コミッターが伝える、"Apache Cassandra...
[Cassandra summit Tokyo, 2015] Apache Cassandra日本人コミッターが伝える、"Apache Cassandra...
 
[Cassandra summit Tokyo, 2015] Cassandra 2015 最新情報 by ジョナサン・エリス(Jonathan Ellis)
[Cassandra summit Tokyo, 2015] Cassandra 2015 最新情報 by ジョナサン・エリス(Jonathan Ellis)[Cassandra summit Tokyo, 2015] Cassandra 2015 最新情報 by ジョナサン・エリス(Jonathan Ellis)
[Cassandra summit Tokyo, 2015] Cassandra 2015 最新情報 by ジョナサン・エリス(Jonathan Ellis)
 
[db tech showcase Tokyo 2015] E35: Web, IoT, モバイル時代のデータベース、Apache Cassandraを学ぼう
[db tech showcase Tokyo 2015] E35: Web, IoT, モバイル時代のデータベース、Apache Cassandraを学ぼう[db tech showcase Tokyo 2015] E35: Web, IoT, モバイル時代のデータベース、Apache Cassandraを学ぼう
[db tech showcase Tokyo 2015] E35: Web, IoT, モバイル時代のデータベース、Apache Cassandraを学ぼう
 
[db tech showcase Tokyo 2015] A27: RDBエンジニアの為のNOSQL, 今どうしてNOSQLなのか?
[db tech showcase Tokyo 2015] A27: RDBエンジニアの為のNOSQL, 今どうしてNOSQLなのか?[db tech showcase Tokyo 2015] A27: RDBエンジニアの為のNOSQL, 今どうしてNOSQLなのか?
[db tech showcase Tokyo 2015] A27: RDBエンジニアの為のNOSQL, 今どうしてNOSQLなのか?
 

Último

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Último (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Investigation of Transactions in Cassandra

  • 1. Investigation of Transactions in Cassandra Cassandra Meetup in Tokyo, Fall 2015 December 2, 2015 Ian Chen Rakuten Inc.
  • 2. Cassandra usage at Rakuten •  Cassandra  nodes:  400+  (many  clusters)   •  Data  size:  5B+  records   •  Rows  accessed/sec:    450k+  (busiest  cluster)   •  Largest  cluster:  90+  nodes   •  Versions:  0.8,  1.2+,  2.0+   •  Community  feedback  since  v0.8   2
  • 3. New Uses for Cassandra •  Not  just  for  “big  data”   •  Global  scale  applicaQon  data   •  TransacQons  and  more   3
  • 4. 4 Agenda    Consistency  (CAP)  1    Atomicity  (ACID)  2    Isola8on  (ACID)  3    Example  4  
  • 5. 5 The  “C”  is  for  Consistency   “..  any  transacQon  will  bring  the  database  from   one  valid  state  to  another.”   “…all  clients  have  the  same  view  of  the  data.”   CAP  Theorem  “C”   ACID  “C”   Eventually..  
  • 6. 6 Tunable  Consistency   •  Manage  consistency  in  your  applicaQon   •  Decide  consistency  per  transacQon   CONSISTENCY ONE; UPDATE users SET name='IAN' WHERE name='ian'; CONSISTENCY ALL; SELECT * FROM users WHERE name='ian';
  • 7. 7 Strong  Consistency   *  QUORUM  =  (replicaQon  factor  /  2)  +  1     nodes     wri_en   nodes     read   replicaQon   factor   R  +  W  >  N   Write  ONE   Read  ONE   =   WEAK   Write  ONE   Read  ALL   =   STRONG   Write  ALL   Read  ONE   =   STRONG   Write  QUORUM   Read  QUORUM   =   STRONG  
  • 8. 8 “A”  is  for  Atomicity   START TRANSACTION; INSERT INTO users (name, country) VALUES(‘ian’, ‘Australia’); INSERT INTO users (name, country) VALUES(‘meg’, ‘Japan’); COMMIT; // or ROLLBACK aka  transacQon  consistency,  linearizable  consistency,  serial  isolaQon  level   All  succeed  or  none  succeed   SQL:  
  • 9. 9 Cassandra  BATCH   BEGIN BATCH INSERT INTO users (name, country) VALUES(‘ian’, ‘Australia’); INSERT INTO users (name, country) VALUES(‘meg’, ‘Japan’); APPLY BATCH; Guarantees  ALL  will  succeed  or  ALL  will  fail   CQL:  
  • 10. 10 “I”  Is  For  Isola8on   START TRANSACTION; SELECT current_caps FROM bottlecaps WHERE name='ian' FOR UPDATE; UPDATE bottlecaps SET current_caps = current_caps + 1; COMMIT; Is  anyone  else  changing  this  data?   SQL:  
  • 11. 11 Cassandra  Lightweight  Transac8ons   INSERT INTO users (name, country) VALUES(‘ian’, ‘Australia’) IF NOT EXISTS; UPDATE users SET country=‘Japan’ WHERE name=‘ian’ IF country=‘Australia’; Allows  you  to  set  condiQons  of  an  update   CQL:  
  • 12. 12 Op8mis8c  vs  Pessimis8c  Locking   PessimisQc  (SQL)   OpQmisQc  (CQL)   SELECT     FOR  UPDATE   SELECT     FOR  UPDATE   COMMIT   COMMIT   lock   SELECT   SELECT   UPDATE  ..  IF  …   UPDATE  ..  IF  …   Thread  1   Thread  2   lock   Thread  1   Thread  2  
  • 13. 13 PuTng  It  Together   1.  Record a transaction 2.  Keep track of the total 3.  Ensure they are updated atomically Example  
  • 14. 14 name current_caps tx_id amount balance ian 0 tx001 null null Example: Bottlecaps CREATE TABLE bottlecaps ( name text, current_caps int STATIC, tx_id int, amount int, balance int, PRIMARY KEY ((name), tx_id) ); // initialize user INSERT INTO bottlecaps (name, tx_id, current_caps) VALUES ('ian', 'tx001', 0);
  • 15. 15 name current_caps tx_id amount balance ian 10 tx001 null null tx002 10 10 Get Some Caps BEGIN BATCH UPDATE bottlecaps SET current_caps = 10 WHERE name='ian' IF current_caps = 0; INSERT INTO bottlecaps (name, tx_id, amount, balance) VALUES ('ian', 'tx003', 7, 17); APPLY BATCH;
  • 16. 16 name current_caps tx_id amount balance ian 17 tx001 null null tx002 10 10 tx003 7 17 Get Some More Caps BEGIN BATCH UPDATE bottlecaps SET current_caps = 17 WHERE name='ian' IF current_caps = 10; INSERT INTO bottlecaps (name, tx_id, amount, balance) VALUES ('ian', 'tx003', 7, 17); APPLY BATCH;
  • 17. 17 name current_caps tx_id amount balance ian 2 tx001 null null tx002 10 10 tx003 7 17 tx004 -15 2 Spend 15 Caps BEGIN BATCH UPDATE bottlecaps SET current_caps = 2 WHERE name='ian' IF current_caps = 17; INSERT INTO bottlecaps (name, tx_id, amount, balance) VALUES ('ian', 'tx004', -15, 2); APPLY BATCH;
  • 18. 18 Summary   Do  the  work  in  your  applicaQon  code.     1.  Consistency  across  all  nodes   •  Tune  Cassandra  access  to  behave  with  “strong  consistency”     2.  Atomicity  of  TransacQons   •  Use  Cassandra  BATCH   3.  IsolaQon  of  TransacQons   •  Use  a  Lightweight  TransacQon  
  • 19. 19 Thanks  ☺     Ian  Chen   ian.chen@rakuten.com   @icchanosaur