SlideShare a Scribd company logo
Apache Cassandra 2.0
http://www.stealth.ly
Joe Stein
About me
 Tweets @allthingshadoop
 All Things Hadoop Blog & Podcast – http://www.allthingshadoop.com
 Watched 0.3 from a distance
 Tried to integrated C* into my stack using 0.4 and 0.5 and 0.6
 0.7 was awesome! Expiring columns, live schema updates, hadoop output
 0.8 things got more interesting with counters and I did our first prod deploy, partial
 1.0 it all came together for us with compression, full deploy
 Cassandra in prod supported over 100 million daily unique mobile devices
 Born again into CQL3
 Apache Kafka http://kafka.apache.org/ committer & PMC member
 Founder & Principal Consultant of Big Data Open Source Security LLC – http://www.stealth.ly
 BDOSS is all about the "glue" and helping companies to not only figure out what Big Data
Infrastructure Components to use but also how to change their existing (or build new)
systems to work with them.
 Working with clients on new projects using Cassandra 2.0
Apache Cassandra 2.0
 Based on Big Table & Dynamo
 High Performance
 Reliable / Available
 Massively Scalable
 Easy To Use
 Developer Productivity Focused
What’s new in C* 2.0
 Finalized some legacy items
 CQL Improvements
 Lightweight Transactions
 Triggers
 Compaction Improvements
 Eager Retries
 More, More, More!!!
Super Columns refactored to use
composite keys instead
Virtual Nodes are the default
CQL Improvements
 Support for multiple prepared statements in batch
 Prepared statement for the consistency level, timestamp and ttl
 Add cursor API/auto paging to the native CQL protocol
 Support indexes on composite column components
 ALTER TABLE to DROP a column
 Column alias in SELECT statement
 SASL (Simple Authentication and Security Layer ) support for improved authentication
 Conditional DDL - Conditionally tests for the existence of a table, keyspace, or index before
issuing a DROP or CREATE statement using IF EXISTS or IF NOT EXISTS
 Support for an empty list of values in the IN clause of SELECT, UPDATE, and DELETE
commands, useful in Java Driver applications when passing empty arrays as arguments for the
IN clause
 Imports and exports CSV (comma-separated values) data to and from Cassandra 1.1.3 and
higher.
COPY table_name ( column, ...)
FROM ( 'file_name' | STDIN ) or TO ( 'file_name' | STDOUT )
WITH option = 'value' AND ...
Lightweight Transactions – Why?
 Cassandra can provide strong consistency with quorum reads & writes
 A write must be written to the commit log and memory table on a quorum of
replica nodes.
 Quorum = (replication_factor / 2) + 1 (rounded down to a whole number)
 This is sometimes not enough when transactions need to be handled in
sequence (linearized) or when operating concurrently achieve the expected
results without race conditions.
 "Strong" consistency is not enough to prevent race conditions. The classic
example is user account creation: we want to ensure usernames are unique,
so we only want to signal account creation success if nobody else has created
the account yet. But naive read-then-write allows clients to race and both
think they have a green light to create.
Lightweight Transactions - "when you
really need it," not for all your updates.
 Prepare: the coordinator generates a ballot (timeUUID in our case) and asks replicas to (a) promise
not to accept updates from older ballots and (b) tell us about the most recent update it has already
accepted.
 Read: we perform a read (of committed values) between the prepare and accept phases. RETURNS
HERE IF CAS failure
 Accept: if a majority of replicas reply, the coordinator asks replicas to accept the value of the
highest proposal ballot it heard about, or a new value if no in-progress proposals were reported.
 Commit (Learn): if a majority of replicas acknowledge the accept request, we can commit the new
value.
 The coordinator sends a commit message to all replicas with the ballot and value.
 Because of Prepare & Accept, this will be the highest-seen commit ballot. The replicas will note that, and send
it with subsequent promise replies. This allows us to discard acceptance records for successfully committed
replicas, without allowing incomplete proposals to commit erroneously later on.
 1 second default timeout for total of above operations configured in cas_contention_timeout_in_ms
 For more details on exactly how this works, look at the code 
https://github.com/apache/cassandra/blob/cassandra-
2.0.1/src/java/org/apache/cassandra/service/StorageProxy.java#L202
Lightweight Transactions
How do we use it?
 Is isolated to the “partition key” for a CQL3 table
 INSERT
 IF NOT EXISTS
 i.e. INSERT INTO users (username, email, full_name) values (‘hellocas',
cas@updateme.com', ‘Hello World CAS', 1) IF NOT EXISTS;
 UPDATE
 IF column = some_value
 IF map[column] = some_value
 The some_value is what you read or expected the value to be prior to your change
 i.e. UPDATE inventory set orderHistory[(now)] = uuid, total[wharehouse13] = 7 where
itemID = uuid IF map[wherehouse13] = 8;
 Conditional updates are not allowed in batches
 The columns updated do NOT have to be the same as the columns in the IF clause.
Trigger (Experimental)
 Experimental = Expect the API to change and your triggers to have to be
refactored in 2.1 … provide feedback to the community if you use this feature
its how we make C* better!!!
 Asynchronous triggers is a basic mechanism to implement various use cases of
asynchronous execution of application code at database side. For example to
support indexes and materialized views, online analytics, push-based data
propagation.
 Basically it takes a RowMutation that is occurring and allows you to pass back
other RowMutation(s) you also want to occur 
 triggers on counter tables are generally not supported (counter mutations are
not allowed inside logged batches for obvious reasons – they aren’t
idempotent).
Trigger Example
 https://github.com/apache/cassandra/tree/trunk/examples/triggers
 RowKey:ColumnName:Value to Value:ColumnName:RowKey
 10214124124 – username = to joestein – username = 10214124124
 CREATE TRIGGER test1 ON "Keyspace1"."Standard1" EXECUTE ('org.apache.cassandra.triggers.InvertedIndex');
 Basically we are returning a row mutation from within a jar so we can do anything we want pretty much
public Collection<RowMutation> augment(ByteBuffer key, ColumnFamily update) {
List<RowMutation> mutations = new ArrayList<RowMutation>();
for (ByteBuffer name : update.getColumnNames()) {
RowMutation mutation = new
RowMutation(properties.getProperty("keyspace"), update.getColumn(name).value());
mutation.add(properties.getProperty("columnfamily"), name, key, System.currentTimeMillis());
mutations.add(mutation);
}
return mutations;
}
Improved Compaction
 During compaction, Cassandra combines multiple data files to improve the
performance of partition scans and to reclaim space from deleted data.
 SizeTieredCompactionStrategy: The default compaction strategy. This strategy
gathers SSTables of similar size and compacts them together into a larger SSTable
This strategy is best suited for column families with insert-mostly workloads that
are not read as frequently. This strategy also requires closer monitoring of disk
utilization because (as a worst case scenario) a column family can temporarily
double in size while a compaction is in progress..
 LeveledCompactionStrategy: Introduced in Cassandra 1.0, this strategy creates
SSTables of a fixed, relatively small size (5 MB by default) that are grouped into
levels. Within each level, SSTables are guaranteed to be non-overlapping. Each
level (L0, L1, L2 and so on) is 10 times as large as the previous. This strategy is
best suited for column families with read-heavy workloads that also have frequent
updates to existing rows. When using this strategy, you want to keep an eye on
read latency performance for the column family. If a node cannot keep up with
the write workload and pending compactions are piling up, then read performance
will degrade for a longer period of time….
Leveled Compaction – in theory
 Reads are through a small amount of files making it performant
 Compaction happens fast enough for the new L0 tier coming in
Leveled Compaction – high write load
 This will cause read latency using level compaction when the tiered
compaction can’t keep up with the writes coming in
Leveled Compaction
 Hybrid – best of both worlds 
Eager Retries
 Speculative execution for reads
 Keeps metrics of read response times to nodes
 Avoid query timeouts by sending redundant requests to other replicas if too
much time elapses on the original request
 ALWAYS
 99th (Default)
 X percentile
 X ms
 NONE
Eager Retries – in action
The JIRA for this test
More, More, More!!!
 The java heap and GC has not been able to keep pace with the heap to data ratio with the
structures that C* has that can be cleaned up with manual garbage collection…. This was
done initially started in 1.2 and finished up in 2.0.
 New commands to disable background compactions nodetool disableautocompaction and
nodetool enableautocompaction
 Auto_bootstrapping of a single-token node with no initial_token
 Timestamp condition eliminates sstable seeks with sstable holding min/max timestamp for
each file skipping unnecessary files
 Thrift users got a major bump in performance using a LMAX disruptor implementation
 Java 7 is now required
 Level compaction information is moved into the sstables
 Streaming has been rewritten – better control, traceability and performance!
 Removed row level bloom filters for columns
 Row reads during compaction halved … doubling the speed

More Related Content

What's hot (20)

PDF
Introduction to Apache Cassandra
Robert Stupp
 
PPTX
An Overview of Apache Cassandra
DataStax
 
PDF
Cassandra Day Atlanta 2015: Introduction to Apache Cassandra & DataStax Enter...
DataStax Academy
 
PDF
Cassandra multi-datacenter operations essentials
Julien Anguenot
 
PDF
Distribute Key Value Store
Santal Li
 
PPT
NOSQL Database: Apache Cassandra
Folio3 Software
 
PPTX
Tales From The Front: An Architecture For Multi-Data Center Scalable Applicat...
DataStax Academy
 
ODP
Introduciton to Apache Cassandra for Java Developers (JavaOne)
zznate
 
PDF
Understanding Data Consistency in Apache Cassandra
DataStax
 
PPTX
Cassandra concepts, patterns and anti-patterns
Dave Gardner
 
PPTX
Learn Cassandra at edureka!
Edureka!
 
ODP
Intro to cassandra
Aaron Ploetz
 
PPT
Cassandra architecture
T Jake Luciani
 
PDF
Cassandra background-and-architecture
Markus Klems
 
PPTX
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
DataStax
 
PPTX
Cassandra internals
narsiman
 
PPTX
One Billion Black Friday Shoppers on a Distributed Data Store (Fahd Siddiqui,...
DataStax
 
PPTX
Apache Cassandra Developer Training Slide Deck
DataStax Academy
 
PDF
Apache Cassandra in the Real World
Jeremy Hanna
 
PDF
Introduction to Cassandra
SoftwareMill
 
Introduction to Apache Cassandra
Robert Stupp
 
An Overview of Apache Cassandra
DataStax
 
Cassandra Day Atlanta 2015: Introduction to Apache Cassandra & DataStax Enter...
DataStax Academy
 
Cassandra multi-datacenter operations essentials
Julien Anguenot
 
Distribute Key Value Store
Santal Li
 
NOSQL Database: Apache Cassandra
Folio3 Software
 
Tales From The Front: An Architecture For Multi-Data Center Scalable Applicat...
DataStax Academy
 
Introduciton to Apache Cassandra for Java Developers (JavaOne)
zznate
 
Understanding Data Consistency in Apache Cassandra
DataStax
 
Cassandra concepts, patterns and anti-patterns
Dave Gardner
 
Learn Cassandra at edureka!
Edureka!
 
Intro to cassandra
Aaron Ploetz
 
Cassandra architecture
T Jake Luciani
 
Cassandra background-and-architecture
Markus Klems
 
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
DataStax
 
Cassandra internals
narsiman
 
One Billion Black Friday Shoppers on a Distributed Data Store (Fahd Siddiqui,...
DataStax
 
Apache Cassandra Developer Training Slide Deck
DataStax Academy
 
Apache Cassandra in the Real World
Jeremy Hanna
 
Introduction to Cassandra
SoftwareMill
 

Viewers also liked (20)

PDF
Cassandra 2.0 to 2.1
Johnny Miller
 
PPTX
Cassandra
Pooja GV
 
PPTX
jstein.cassandra.nyc.2011
Joe Stein
 
PDF
Cassandra - A Decentralized Structured Storage System
Varad Meru
 
PPTX
Storing Time Series Metrics With Cassandra and Composite Columns
Joe Stein
 
PDF
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
DataStax
 
PPTX
Cassandra - A decentralized storage system
Arunit Gupta
 
PDF
Developing Realtime Data Pipelines With Apache Kafka
Joe Stein
 
PDF
Data Pipeline with Kafka
Peerapat Asoktummarungsri
 
PPTX
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Joe Stein
 
PPTX
Containerized Data Persistence on Mesos
Joe Stein
 
PPTX
Developing Real-Time Data Pipelines with Apache Kafka
Joe Stein
 
PPTX
Making Apache Kafka Elastic with Apache Mesos
Joe Stein
 
PDF
Apache Cassandra Lesson: Data Modelling and CQL3
Markus Klems
 
PPTX
Introduction Apache Kafka
Joe Stein
 
PPTX
Developing Frameworks for Apache Mesos
Joe Stein
 
PPTX
Hadoop Streaming Tutorial With Python
Joe Stein
 
PDF
Streaming Processing with a Distributed Commit Log
Joe Stein
 
PDF
Cassandra 3.0
Robert Stupp
 
PPTX
Developing with the Go client for Apache Kafka
Joe Stein
 
Cassandra 2.0 to 2.1
Johnny Miller
 
Cassandra
Pooja GV
 
jstein.cassandra.nyc.2011
Joe Stein
 
Cassandra - A Decentralized Structured Storage System
Varad Meru
 
Storing Time Series Metrics With Cassandra and Composite Columns
Joe Stein
 
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
DataStax
 
Cassandra - A decentralized storage system
Arunit Gupta
 
Developing Realtime Data Pipelines With Apache Kafka
Joe Stein
 
Data Pipeline with Kafka
Peerapat Asoktummarungsri
 
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Joe Stein
 
Containerized Data Persistence on Mesos
Joe Stein
 
Developing Real-Time Data Pipelines with Apache Kafka
Joe Stein
 
Making Apache Kafka Elastic with Apache Mesos
Joe Stein
 
Apache Cassandra Lesson: Data Modelling and CQL3
Markus Klems
 
Introduction Apache Kafka
Joe Stein
 
Developing Frameworks for Apache Mesos
Joe Stein
 
Hadoop Streaming Tutorial With Python
Joe Stein
 
Streaming Processing with a Distributed Commit Log
Joe Stein
 
Cassandra 3.0
Robert Stupp
 
Developing with the Go client for Apache Kafka
Joe Stein
 
Ad

Similar to Apache Cassandra 2.0 (20)

PDF
[Cassandra summit Tokyo, 2015] Cassandra 2015 最新情報 by ジョナサン・エリス(Jonathan Ellis)
datastaxjp
 
PDF
A Deep Dive into Apache Cassandra for .NET Developers
Luke Tillman
 
PDF
October 2013 Cassandra Boulder MeetUp.key
Michael Shaler
 
PDF
London + Dublin Cassandra 2.0
jbellis
 
PDF
Cassandra 2.1
jbellis
 
PDF
CQL In Cassandra 1.0 (and beyond)
Eric Evans
 
PPTX
final demo 1.pptx about Property rental system
ravindrakulkarni478
 
PDF
Trivadis TechEvent 2016 Big Data Cassandra, wieso brauche ich das? by Jan Ott
Trivadis
 
PPTX
Cassandra20141113
Brian Enochson
 
PDF
What's new in Cassandra 2.0
iamaleksey
 
PDF
Managing Cassandra at Scale by Al Tobey
DataStax Academy
 
PDF
Cassandra 2012
beobal
 
PDF
Deep Dive into Cassandra
Brent Theisen
 
PDF
Apache Cassandra - Data modelling
Alex Thompson
 
PDF
Big Data Grows Up - A (re)introduction to Cassandra
Robbie Strickland
 
PDF
Introduction to Apache Cassandra
Luke Tillman
 
PPTX
Cassandra under the hood
Andriy Rymar
 
PPTX
Learning Cassandra NoSQL
Pankaj Khattar
 
PDF
About "Apache Cassandra"
Jihyun Ahn
 
PDF
Tokyo Cassandra Summit 2014: Apache Cassandra 2.0 + 2.1 by Jonathan Ellis
DataStax Academy
 
[Cassandra summit Tokyo, 2015] Cassandra 2015 最新情報 by ジョナサン・エリス(Jonathan Ellis)
datastaxjp
 
A Deep Dive into Apache Cassandra for .NET Developers
Luke Tillman
 
October 2013 Cassandra Boulder MeetUp.key
Michael Shaler
 
London + Dublin Cassandra 2.0
jbellis
 
Cassandra 2.1
jbellis
 
CQL In Cassandra 1.0 (and beyond)
Eric Evans
 
final demo 1.pptx about Property rental system
ravindrakulkarni478
 
Trivadis TechEvent 2016 Big Data Cassandra, wieso brauche ich das? by Jan Ott
Trivadis
 
Cassandra20141113
Brian Enochson
 
What's new in Cassandra 2.0
iamaleksey
 
Managing Cassandra at Scale by Al Tobey
DataStax Academy
 
Cassandra 2012
beobal
 
Deep Dive into Cassandra
Brent Theisen
 
Apache Cassandra - Data modelling
Alex Thompson
 
Big Data Grows Up - A (re)introduction to Cassandra
Robbie Strickland
 
Introduction to Apache Cassandra
Luke Tillman
 
Cassandra under the hood
Andriy Rymar
 
Learning Cassandra NoSQL
Pankaj Khattar
 
About "Apache Cassandra"
Jihyun Ahn
 
Tokyo Cassandra Summit 2014: Apache Cassandra 2.0 + 2.1 by Jonathan Ellis
DataStax Academy
 
Ad

More from Joe Stein (12)

PDF
SMACK Stack 1.1
Joe Stein
 
PDF
Get started with Developing Frameworks in Go on Apache Mesos
Joe Stein
 
PPTX
Introduction To Apache Mesos
Joe Stein
 
PPTX
Real-Time Log Analysis with Apache Mesos, Kafka and Cassandra
Joe Stein
 
PPTX
Real-Time Distributed and Reactive Systems with Apache Kafka and Apache Accumulo
Joe Stein
 
PPTX
Building and Deploying Application to Apache Mesos
Joe Stein
 
PPTX
Apache Kafka, HDFS, Accumulo and more on Mesos
Joe Stein
 
PPTX
Current and Future of Apache Kafka
Joe Stein
 
PPTX
Introduction to Apache Mesos
Joe Stein
 
PDF
Developing Real-Time Data Pipelines with Apache Kafka
Joe Stein
 
PPTX
Real-time streaming and data pipelines with Apache Kafka
Joe Stein
 
PPTX
Apache Kafka
Joe Stein
 
SMACK Stack 1.1
Joe Stein
 
Get started with Developing Frameworks in Go on Apache Mesos
Joe Stein
 
Introduction To Apache Mesos
Joe Stein
 
Real-Time Log Analysis with Apache Mesos, Kafka and Cassandra
Joe Stein
 
Real-Time Distributed and Reactive Systems with Apache Kafka and Apache Accumulo
Joe Stein
 
Building and Deploying Application to Apache Mesos
Joe Stein
 
Apache Kafka, HDFS, Accumulo and more on Mesos
Joe Stein
 
Current and Future of Apache Kafka
Joe Stein
 
Introduction to Apache Mesos
Joe Stein
 
Developing Real-Time Data Pipelines with Apache Kafka
Joe Stein
 
Real-time streaming and data pipelines with Apache Kafka
Joe Stein
 
Apache Kafka
Joe Stein
 

Recently uploaded (20)

PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 

Apache Cassandra 2.0

  • 2. About me  Tweets @allthingshadoop  All Things Hadoop Blog & Podcast – http://www.allthingshadoop.com  Watched 0.3 from a distance  Tried to integrated C* into my stack using 0.4 and 0.5 and 0.6  0.7 was awesome! Expiring columns, live schema updates, hadoop output  0.8 things got more interesting with counters and I did our first prod deploy, partial  1.0 it all came together for us with compression, full deploy  Cassandra in prod supported over 100 million daily unique mobile devices  Born again into CQL3  Apache Kafka http://kafka.apache.org/ committer & PMC member  Founder & Principal Consultant of Big Data Open Source Security LLC – http://www.stealth.ly  BDOSS is all about the "glue" and helping companies to not only figure out what Big Data Infrastructure Components to use but also how to change their existing (or build new) systems to work with them.  Working with clients on new projects using Cassandra 2.0
  • 3. Apache Cassandra 2.0  Based on Big Table & Dynamo  High Performance  Reliable / Available  Massively Scalable  Easy To Use  Developer Productivity Focused
  • 4. What’s new in C* 2.0  Finalized some legacy items  CQL Improvements  Lightweight Transactions  Triggers  Compaction Improvements  Eager Retries  More, More, More!!!
  • 5. Super Columns refactored to use composite keys instead
  • 6. Virtual Nodes are the default
  • 7. CQL Improvements  Support for multiple prepared statements in batch  Prepared statement for the consistency level, timestamp and ttl  Add cursor API/auto paging to the native CQL protocol  Support indexes on composite column components  ALTER TABLE to DROP a column  Column alias in SELECT statement  SASL (Simple Authentication and Security Layer ) support for improved authentication  Conditional DDL - Conditionally tests for the existence of a table, keyspace, or index before issuing a DROP or CREATE statement using IF EXISTS or IF NOT EXISTS  Support for an empty list of values in the IN clause of SELECT, UPDATE, and DELETE commands, useful in Java Driver applications when passing empty arrays as arguments for the IN clause  Imports and exports CSV (comma-separated values) data to and from Cassandra 1.1.3 and higher. COPY table_name ( column, ...) FROM ( 'file_name' | STDIN ) or TO ( 'file_name' | STDOUT ) WITH option = 'value' AND ...
  • 8. Lightweight Transactions – Why?  Cassandra can provide strong consistency with quorum reads & writes  A write must be written to the commit log and memory table on a quorum of replica nodes.  Quorum = (replication_factor / 2) + 1 (rounded down to a whole number)  This is sometimes not enough when transactions need to be handled in sequence (linearized) or when operating concurrently achieve the expected results without race conditions.  "Strong" consistency is not enough to prevent race conditions. The classic example is user account creation: we want to ensure usernames are unique, so we only want to signal account creation success if nobody else has created the account yet. But naive read-then-write allows clients to race and both think they have a green light to create.
  • 9. Lightweight Transactions - "when you really need it," not for all your updates.  Prepare: the coordinator generates a ballot (timeUUID in our case) and asks replicas to (a) promise not to accept updates from older ballots and (b) tell us about the most recent update it has already accepted.  Read: we perform a read (of committed values) between the prepare and accept phases. RETURNS HERE IF CAS failure  Accept: if a majority of replicas reply, the coordinator asks replicas to accept the value of the highest proposal ballot it heard about, or a new value if no in-progress proposals were reported.  Commit (Learn): if a majority of replicas acknowledge the accept request, we can commit the new value.  The coordinator sends a commit message to all replicas with the ballot and value.  Because of Prepare & Accept, this will be the highest-seen commit ballot. The replicas will note that, and send it with subsequent promise replies. This allows us to discard acceptance records for successfully committed replicas, without allowing incomplete proposals to commit erroneously later on.  1 second default timeout for total of above operations configured in cas_contention_timeout_in_ms  For more details on exactly how this works, look at the code  https://github.com/apache/cassandra/blob/cassandra- 2.0.1/src/java/org/apache/cassandra/service/StorageProxy.java#L202
  • 10. Lightweight Transactions How do we use it?  Is isolated to the “partition key” for a CQL3 table  INSERT  IF NOT EXISTS  i.e. INSERT INTO users (username, email, full_name) values (‘hellocas', [email protected]', ‘Hello World CAS', 1) IF NOT EXISTS;  UPDATE  IF column = some_value  IF map[column] = some_value  The some_value is what you read or expected the value to be prior to your change  i.e. UPDATE inventory set orderHistory[(now)] = uuid, total[wharehouse13] = 7 where itemID = uuid IF map[wherehouse13] = 8;  Conditional updates are not allowed in batches  The columns updated do NOT have to be the same as the columns in the IF clause.
  • 11. Trigger (Experimental)  Experimental = Expect the API to change and your triggers to have to be refactored in 2.1 … provide feedback to the community if you use this feature its how we make C* better!!!  Asynchronous triggers is a basic mechanism to implement various use cases of asynchronous execution of application code at database side. For example to support indexes and materialized views, online analytics, push-based data propagation.  Basically it takes a RowMutation that is occurring and allows you to pass back other RowMutation(s) you also want to occur   triggers on counter tables are generally not supported (counter mutations are not allowed inside logged batches for obvious reasons – they aren’t idempotent).
  • 12. Trigger Example  https://github.com/apache/cassandra/tree/trunk/examples/triggers  RowKey:ColumnName:Value to Value:ColumnName:RowKey  10214124124 – username = to joestein – username = 10214124124  CREATE TRIGGER test1 ON "Keyspace1"."Standard1" EXECUTE ('org.apache.cassandra.triggers.InvertedIndex');  Basically we are returning a row mutation from within a jar so we can do anything we want pretty much public Collection<RowMutation> augment(ByteBuffer key, ColumnFamily update) { List<RowMutation> mutations = new ArrayList<RowMutation>(); for (ByteBuffer name : update.getColumnNames()) { RowMutation mutation = new RowMutation(properties.getProperty("keyspace"), update.getColumn(name).value()); mutation.add(properties.getProperty("columnfamily"), name, key, System.currentTimeMillis()); mutations.add(mutation); } return mutations; }
  • 13. Improved Compaction  During compaction, Cassandra combines multiple data files to improve the performance of partition scans and to reclaim space from deleted data.  SizeTieredCompactionStrategy: The default compaction strategy. This strategy gathers SSTables of similar size and compacts them together into a larger SSTable This strategy is best suited for column families with insert-mostly workloads that are not read as frequently. This strategy also requires closer monitoring of disk utilization because (as a worst case scenario) a column family can temporarily double in size while a compaction is in progress..  LeveledCompactionStrategy: Introduced in Cassandra 1.0, this strategy creates SSTables of a fixed, relatively small size (5 MB by default) that are grouped into levels. Within each level, SSTables are guaranteed to be non-overlapping. Each level (L0, L1, L2 and so on) is 10 times as large as the previous. This strategy is best suited for column families with read-heavy workloads that also have frequent updates to existing rows. When using this strategy, you want to keep an eye on read latency performance for the column family. If a node cannot keep up with the write workload and pending compactions are piling up, then read performance will degrade for a longer period of time….
  • 14. Leveled Compaction – in theory  Reads are through a small amount of files making it performant  Compaction happens fast enough for the new L0 tier coming in
  • 15. Leveled Compaction – high write load  This will cause read latency using level compaction when the tiered compaction can’t keep up with the writes coming in
  • 16. Leveled Compaction  Hybrid – best of both worlds 
  • 17. Eager Retries  Speculative execution for reads  Keeps metrics of read response times to nodes  Avoid query timeouts by sending redundant requests to other replicas if too much time elapses on the original request  ALWAYS  99th (Default)  X percentile  X ms  NONE
  • 18. Eager Retries – in action The JIRA for this test
  • 19. More, More, More!!!  The java heap and GC has not been able to keep pace with the heap to data ratio with the structures that C* has that can be cleaned up with manual garbage collection…. This was done initially started in 1.2 and finished up in 2.0.  New commands to disable background compactions nodetool disableautocompaction and nodetool enableautocompaction  Auto_bootstrapping of a single-token node with no initial_token  Timestamp condition eliminates sstable seeks with sstable holding min/max timestamp for each file skipping unnecessary files  Thrift users got a major bump in performance using a LMAX disruptor implementation  Java 7 is now required  Level compaction information is moved into the sstables  Streaming has been rewritten – better control, traceability and performance!  Removed row level bloom filters for columns  Row reads during compaction halved … doubling the speed