State of Cassandra 2014 
Jonathan Ellis 
Project Chair, Apache Cassandra 
CTO, DataStax 
©2014 DataStax Confidential. Do not distribute without consent.
2.1 http://cassandra.apache.org/download/
Cluster cluster = Cluster.builder() 
.addContactPoint("127.0.0.1") 
.withRetryPolicy( 
DefaultRetryPolicy.INSTANCE) 
.withLoadBalancingPolicy( 
new TokenAwarePolicy( 
new DCAwareRoundRobinPolicy())) 
.build(); 
Session session = cluster.connect("demo"); 
cluster = Cluster( 
contact_points=['127.0.0.1'], 
load_balancing_policy=TokenAwarePolicy( 
DCAwareRoundRobinPolicy( 
local_dc='datacenter1')), 
default_retry_policy = RetryPolicy()) 
session = cluster.connect('demo’) 
Cluster cluster = Cluster.Builder() 
.AddContactPoints("127.0.0.1") 
.WithRetryPolicy( 
DowngradingConsistencyRetryPolicy.INSTANCE) 
.WithLoadBalancingPolicy( 
new TokenAwarePolicy( 
new RoundRobinPolicy()) 
.Build(); 
ISession session = cluster.Connect("demo");
Cassandra’s peer to peer architecture, 
linear scalability and multi data center 
active-active deployment enable mission 
critical eBay features for hundreds of 
millions users every day. 
Feng Qu, principal DBA at eBay Inc
Client Coordinator 
40% 
busy 
90% 
busy 
30% 
busy
Client Coordinator 
40% 
busy 
90% 
busy 
30% 
busy
Client Coordinator 
40% 
busy 
90% 
busy 
30% 
busy
Client Coordinator 
40% 
busy 
90% 
busy 
30% 
Xbusy
Client Coordinator 
40% 
busy 
90% 
busy 
30% 
Xbusy
Client Coordinator 
40% 
busy 
90% 
busy 
30% 
Xbusy
Client Coordinator 
40% 
busy 
90% 
busy 
30% 
Xbusy success
“One of the great things about 
NoSQL is the ability to iterate 
on one's data model as one's 
business requires it.” 
“Everything in one place is 
convenient until it fails. If you 
want to scale and be highly 
available, use Cassandra.” 
Matt Asay 
MongoDB 
Adrian Cockcroft 
Battery Ventures
2.1: Performance
Read performance, 2.0 vs 2.1
Reads, post-compaction (2.0)
Reads, post-compaction (2.1)
Write performance, 2.0 vs 2.1
Competitive performance
Competitive performance 
https://github.com/jbellis/YCSB
2.1: Data modeling
Lightweight transactions
Lightweight transactions 
INSERT INTO users 
(username, name, email, 
password, created_date) 
VALUES ('pmcfadin', 
'Patrick McFadin', 
['patrick@datastax.com'], 
'ba27e03fd9...', 
'2011-06-20 13:50:00') 
IF NOT EXISTS;
Lightweight transactions 
INSERT INTO users 
(username, name, email, 
password, created_date) 
VALUES ('pmcfadin', 
'Patrick McFadin', 
['patrick@datastax.com'], 
'ba27e03fd9...', 
'2011-06-20 13:50:00') 
IF NOT EXISTS; 
INSERT INTO users 
(username, name, email, 
password, created_date) 
VALUES ('pmcfadin', 
'Patrick McFadin', 
['patrick@datastax.com'], 
'ea24e13ad9...', 
'2011-06-20 13:50:01') 
IF NOT EXISTS;
Lightweight transactions 
INSERT INTO users 
(username, name, email, 
password, created_date) 
VALUES ('pmcfadin', 
'Patrick McFadin', 
['patrick@datastax.com'], 
'ba27e03fd9...', 
'2011-06-20 13:50:00') 
IF NOT EXISTS; 
[applied] 
----------- 
True 
INSERT INTO users 
(username, name, email, 
password, created_date) 
VALUES ('pmcfadin', 
'Patrick McFadin', 
['patrick@datastax.com'], 
'ea24e13ad9...', 
'2011-06-20 13:50:01') 
IF NOT EXISTS;
Lightweight transactions 
[applied] | username | created_date | name 
-----------+----------+----------------+---------------- 
False | pmcfadin | 2011-06-20 ... | Patrick McFadin 
INSERT INTO users 
(username, name, email, 
password, created_date) 
VALUES ('pmcfadin', 
'Patrick McFadin', 
['patrick@datastax.com'], 
'ba27e03fd9...', 
'2011-06-20 13:50:00') 
IF NOT EXISTS; 
[applied] 
----------- 
True 
INSERT INTO users 
(username, name, email, 
password, created_date) 
VALUES ('pmcfadin', 
'Patrick McFadin', 
['patrick@datastax.com'], 
'ea24e13ad9...', 
'2011-06-20 13:50:01') 
IF NOT EXISTS;
Static columns (2.0.6) 
CREATE TABLE bills ( 
user text, 
balance int static, 
expense_id int, 
amount int, 
description text, 
paid boolean, 
PRIMARY KEY (user, expense_id) 
);
Static columns + LWT 
CREATE TABLE bills ( 
user text, 
balance int static, 
expense_id int, 
amount int, 
description text, 
paid boolean, 
PRIMARY KEY (user, expense_id) 
); 
BEGIN BATCH 
UPDATE bills SET balance = -116 WHERE user='user1' IF balance = 84; 
INSERT INTO bills (user, expense_id, amount, description, paid) 
VALUES ('user1', 2, 200, 'hotel room', false); 
APPLY BATCH;
Atomic log appends with LWT 
CREATE TABLE log ( 
log_name text, 
seq int static, 
logged_at timeuuid, 
entry text, 
primary key (log_name, logged_at) 
); 
INSERT INTO log (log_name, seq) 
VALUES ('foo', 0);
Atomic log appends with LWT 
BEGIN BATCH 
UPDATE log SET seq = 1 
WHERE log_name = 'foo' 
IF seq = 0; 
INSERT INTO log (log_name, logged_at, entry) 
VALUES ('foo', now(), 'test'); 
APPLY BATCH;
User defined types 
CREATE TYPE address ( 
street text, 
city text, 
zip_code int, 
phones set<text> 
) 
CREATE TABLE users ( 
id uuid PRIMARY KEY, 
name text, 
addresses map<text, frozen<address>> 
) 
SELECT id, name, addresses.city, addresses.phones FROM users; 
id | name | addresses.city | addresses.phones 
--------------------+----------------+-------------------------- 
63bf691f | jbellis | Austin | {'512-4567', '512-9999'}
Collection indexing 
CREATE TABLE songs ( 
id uuid PRIMARY KEY, 
artist text, 
album text, 
title text, 
data blob, 
tags set<text> 
); 
CREATE INDEX song_tags_idx ON songs(tags); 
SELECT * FROM songs WHERE tags CONTAINS 'blues'; 
id | album | artist | tags | title 
----------+---------------+-------------------+-----------------------+------------------ 
5027b27e | Country Blues | Lightnin' Hopkins | {'acoustic', 'blues'} | Worrying My Mind
2.1: Operations
Counters, 2.0
Counters, 2.0 
1. Node A, increment by 1 
Memtable 
A0 1 1 
Commitlog 
A0 1 1 
Value: 1
Counters, 2.0 
2. Node A, increment by 1 
Commitlog 
A0 1 1 
A0 1 1 
Memtable 
A0 2 2 
Value: 2 
1. Node A, increment by 1 
Memtable 
A0 1 1 
Commitlog 
A0 1 1 
Value: 1
Counters, 2.0 
2. Node A, increment by 1 
Commitlog 
A0 1 1 
A0 1 1 
Memtable 
A0 2 2 
Value: 2 
1. Node A, increment by 1 
Memtable 
A0 1 1 
Commitlog 
A0 1 1 
Value: 1 
3. Node A, decrement by 2 
Memtable 
A0 3 0 
Value: 0 
Commit Log 
A0 1 1 
A0 1 1 
A0 1 -2
Counters, 2.1
Counters, 2.1 
1. Node A, increment by 1 
Memtable 
A0 1 1 
Commitlog 
A0 1 1 
Value: 1
Counters, 2.1 
2. Node A, increment by 1 
Commitlog 
A0 1 1 
A0 2 2 
Memtable 
A0 2 2 
Value: 2 
1. Node A, increment by 1 
Memtable 
A0 1 1 
Commitlog 
A0 1 1 
Value: 1
Counters, 2.1 
2. Node A, increment by 1 
Commitlog 
A0 1 1 
A0 2 2 
Memtable 
A0 2 2 
Value: 2 
1. Node A, increment by 1 
Memtable 
A0 1 1 
Commitlog 
A0 1 1 
Value: 1 
3. Node A, decrement by 2 
Memtable 
A0 3 0 
Value: 0 
Commit Log 
A0 1 1 
A0 2 2 
A0 3 0
(low contention)
(high contention)
Regular repair
Regular repair
Regular repair
Incremental repair
Implications for LCS (and STCS) 
bin/nodetool upgradesstables 
tools/bin/sstablerepairedset --is-repaired 
bin/nodetool repair 
bin/nodetool repair -inc
The new row cache 
CREATE TABLE notifications ( 
target_user text, 
notification_id timeuuid, 
source_id uuid, 
source_type text, 
activity text, 
PRIMARY KEY (target_user, notification_id) 
) 
WITH CLUSTERING ORDER BY (notification_id DESC) 
AND caching = 'rows_only' 
AND rows_per_partition_to_cache = '3';
The new row cache 
target_user notification_id source_id source_type activity 
nick e1bd2bcb- d972b679- photo tom liked 
nick 321998c- d972b679- photo jake commented 
nick ea1c5d35- 88a049d5- user mike created account 
nick 5321998c- 64613f27- photo tom commented 
nick 07581439- 076eab7e- user tyler created account 
mike 1c34467a- f04e309f- user tom created account
The new row cache 
target_user notification_id source_id source_type activity 
nick e1bd2bcb- d972b679- photo tom liked 
nick 321998c- d972b679- photo jake commented 
nick ea1c5d35- 88a049d5- user mike created account 
nick 5321998c- 64613f27- photo tom commented 
nick 07581439- 076eab7e- user tyler created account 
mike 1c34467a- f04e309f- user tom created account
The new row cache 
target_user notification_id source_id source_type activity 
nick e1bd2bcb- d972b679- photo tom liked 
nick 321998c- d972b679- photo jake commented 
nick ea1c5d35- 88a049d5- user mike created account 
nick 5321998c- 64613f27- photo tom commented 
nick 07581439- 076eab7e- user tyler created account 
mike 1c34467a- f04e309f- user tom created account
2.1: Testing & QA
Cassandra summit keynote 2014
Cassandra summit keynote 2014

Cassandra summit keynote 2014

  • 1.
    State of Cassandra2014 Jonathan Ellis Project Chair, Apache Cassandra CTO, DataStax ©2014 DataStax Confidential. Do not distribute without consent.
  • 2.
  • 5.
    Cluster cluster =Cluster.builder() .addContactPoint("127.0.0.1") .withRetryPolicy( DefaultRetryPolicy.INSTANCE) .withLoadBalancingPolicy( new TokenAwarePolicy( new DCAwareRoundRobinPolicy())) .build(); Session session = cluster.connect("demo"); cluster = Cluster( contact_points=['127.0.0.1'], load_balancing_policy=TokenAwarePolicy( DCAwareRoundRobinPolicy( local_dc='datacenter1')), default_retry_policy = RetryPolicy()) session = cluster.connect('demo’) Cluster cluster = Cluster.Builder() .AddContactPoints("127.0.0.1") .WithRetryPolicy( DowngradingConsistencyRetryPolicy.INSTANCE) .WithLoadBalancingPolicy( new TokenAwarePolicy( new RoundRobinPolicy()) .Build(); ISession session = cluster.Connect("demo");
  • 6.
    Cassandra’s peer topeer architecture, linear scalability and multi data center active-active deployment enable mission critical eBay features for hundreds of millions users every day. Feng Qu, principal DBA at eBay Inc
  • 8.
    Client Coordinator 40% busy 90% busy 30% busy
  • 9.
    Client Coordinator 40% busy 90% busy 30% busy
  • 10.
    Client Coordinator 40% busy 90% busy 30% busy
  • 11.
    Client Coordinator 40% busy 90% busy 30% Xbusy
  • 12.
    Client Coordinator 40% busy 90% busy 30% Xbusy
  • 13.
    Client Coordinator 40% busy 90% busy 30% Xbusy
  • 14.
    Client Coordinator 40% busy 90% busy 30% Xbusy success
  • 19.
    “One of thegreat things about NoSQL is the ability to iterate on one's data model as one's business requires it.” “Everything in one place is convenient until it fails. If you want to scale and be highly available, use Cassandra.” Matt Asay MongoDB Adrian Cockcroft Battery Ventures
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
    Lightweight transactions INSERTINTO users (username, name, email, password, created_date) VALUES ('pmcfadin', 'Patrick McFadin', ['patrick@datastax.com'], 'ba27e03fd9...', '2011-06-20 13:50:00') IF NOT EXISTS;
  • 32.
    Lightweight transactions INSERTINTO users (username, name, email, password, created_date) VALUES ('pmcfadin', 'Patrick McFadin', ['patrick@datastax.com'], 'ba27e03fd9...', '2011-06-20 13:50:00') IF NOT EXISTS; INSERT INTO users (username, name, email, password, created_date) VALUES ('pmcfadin', 'Patrick McFadin', ['patrick@datastax.com'], 'ea24e13ad9...', '2011-06-20 13:50:01') IF NOT EXISTS;
  • 33.
    Lightweight transactions INSERTINTO users (username, name, email, password, created_date) VALUES ('pmcfadin', 'Patrick McFadin', ['patrick@datastax.com'], 'ba27e03fd9...', '2011-06-20 13:50:00') IF NOT EXISTS; [applied] ----------- True INSERT INTO users (username, name, email, password, created_date) VALUES ('pmcfadin', 'Patrick McFadin', ['patrick@datastax.com'], 'ea24e13ad9...', '2011-06-20 13:50:01') IF NOT EXISTS;
  • 34.
    Lightweight transactions [applied]| username | created_date | name -----------+----------+----------------+---------------- False | pmcfadin | 2011-06-20 ... | Patrick McFadin INSERT INTO users (username, name, email, password, created_date) VALUES ('pmcfadin', 'Patrick McFadin', ['patrick@datastax.com'], 'ba27e03fd9...', '2011-06-20 13:50:00') IF NOT EXISTS; [applied] ----------- True INSERT INTO users (username, name, email, password, created_date) VALUES ('pmcfadin', 'Patrick McFadin', ['patrick@datastax.com'], 'ea24e13ad9...', '2011-06-20 13:50:01') IF NOT EXISTS;
  • 35.
    Static columns (2.0.6) CREATE TABLE bills ( user text, balance int static, expense_id int, amount int, description text, paid boolean, PRIMARY KEY (user, expense_id) );
  • 36.
    Static columns +LWT CREATE TABLE bills ( user text, balance int static, expense_id int, amount int, description text, paid boolean, PRIMARY KEY (user, expense_id) ); BEGIN BATCH UPDATE bills SET balance = -116 WHERE user='user1' IF balance = 84; INSERT INTO bills (user, expense_id, amount, description, paid) VALUES ('user1', 2, 200, 'hotel room', false); APPLY BATCH;
  • 37.
    Atomic log appendswith LWT CREATE TABLE log ( log_name text, seq int static, logged_at timeuuid, entry text, primary key (log_name, logged_at) ); INSERT INTO log (log_name, seq) VALUES ('foo', 0);
  • 38.
    Atomic log appendswith LWT BEGIN BATCH UPDATE log SET seq = 1 WHERE log_name = 'foo' IF seq = 0; INSERT INTO log (log_name, logged_at, entry) VALUES ('foo', now(), 'test'); APPLY BATCH;
  • 39.
    User defined types CREATE TYPE address ( street text, city text, zip_code int, phones set<text> ) CREATE TABLE users ( id uuid PRIMARY KEY, name text, addresses map<text, frozen<address>> ) SELECT id, name, addresses.city, addresses.phones FROM users; id | name | addresses.city | addresses.phones --------------------+----------------+-------------------------- 63bf691f | jbellis | Austin | {'512-4567', '512-9999'}
  • 40.
    Collection indexing CREATETABLE songs ( id uuid PRIMARY KEY, artist text, album text, title text, data blob, tags set<text> ); CREATE INDEX song_tags_idx ON songs(tags); SELECT * FROM songs WHERE tags CONTAINS 'blues'; id | album | artist | tags | title ----------+---------------+-------------------+-----------------------+------------------ 5027b27e | Country Blues | Lightnin' Hopkins | {'acoustic', 'blues'} | Worrying My Mind
  • 41.
  • 42.
  • 43.
    Counters, 2.0 1.Node A, increment by 1 Memtable A0 1 1 Commitlog A0 1 1 Value: 1
  • 44.
    Counters, 2.0 2.Node A, increment by 1 Commitlog A0 1 1 A0 1 1 Memtable A0 2 2 Value: 2 1. Node A, increment by 1 Memtable A0 1 1 Commitlog A0 1 1 Value: 1
  • 45.
    Counters, 2.0 2.Node A, increment by 1 Commitlog A0 1 1 A0 1 1 Memtable A0 2 2 Value: 2 1. Node A, increment by 1 Memtable A0 1 1 Commitlog A0 1 1 Value: 1 3. Node A, decrement by 2 Memtable A0 3 0 Value: 0 Commit Log A0 1 1 A0 1 1 A0 1 -2
  • 46.
  • 47.
    Counters, 2.1 1.Node A, increment by 1 Memtable A0 1 1 Commitlog A0 1 1 Value: 1
  • 48.
    Counters, 2.1 2.Node A, increment by 1 Commitlog A0 1 1 A0 2 2 Memtable A0 2 2 Value: 2 1. Node A, increment by 1 Memtable A0 1 1 Commitlog A0 1 1 Value: 1
  • 49.
    Counters, 2.1 2.Node A, increment by 1 Commitlog A0 1 1 A0 2 2 Memtable A0 2 2 Value: 2 1. Node A, increment by 1 Memtable A0 1 1 Commitlog A0 1 1 Value: 1 3. Node A, decrement by 2 Memtable A0 3 0 Value: 0 Commit Log A0 1 1 A0 2 2 A0 3 0
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
    Implications for LCS(and STCS) bin/nodetool upgradesstables tools/bin/sstablerepairedset --is-repaired bin/nodetool repair bin/nodetool repair -inc
  • 57.
    The new rowcache CREATE TABLE notifications ( target_user text, notification_id timeuuid, source_id uuid, source_type text, activity text, PRIMARY KEY (target_user, notification_id) ) WITH CLUSTERING ORDER BY (notification_id DESC) AND caching = 'rows_only' AND rows_per_partition_to_cache = '3';
  • 58.
    The new rowcache target_user notification_id source_id source_type activity nick e1bd2bcb- d972b679- photo tom liked nick 321998c- d972b679- photo jake commented nick ea1c5d35- 88a049d5- user mike created account nick 5321998c- 64613f27- photo tom commented nick 07581439- 076eab7e- user tyler created account mike 1c34467a- f04e309f- user tom created account
  • 59.
    The new rowcache target_user notification_id source_id source_type activity nick e1bd2bcb- d972b679- photo tom liked nick 321998c- d972b679- photo jake commented nick ea1c5d35- 88a049d5- user mike created account nick 5321998c- 64613f27- photo tom commented nick 07581439- 076eab7e- user tyler created account mike 1c34467a- f04e309f- user tom created account
  • 60.
    The new rowcache target_user notification_id source_id source_type activity nick e1bd2bcb- d972b679- photo tom liked nick 321998c- d972b679- photo jake commented nick ea1c5d35- 88a049d5- user mike created account nick 5321998c- 64613f27- photo tom commented nick 07581439- 076eab7e- user tyler created account mike 1c34467a- f04e309f- user tom created account
  • 61.