SlideShare a Scribd company logo
Building a Key-Value
Store with Cassandra
Kiwi PyCon 2010
Aaron Morton @aaronmorton
Weta Digital
1
Why Cassandra?
• Part of a larger project started earlier
this year to build new systems for code
running on the render farm of 35,000
cores
• Larger project goals were Scalability,
Reliability, Flexible Schema
2
How about MySQL ?
• It works. But...
• Schema changes
• Write redundancy
• Query language mismatch
• So went looking for the right tool for the
job
3
Redis ?
• Fast, flexible. But...
• Single core limit
• Replication, but no cluster (itʼs
coming)
• Limited support options
4
Couch DB ?
• Schema free, scalable (sort of),
redundant (sort of). But...
• Single write thread limit
• Replication, but no cluster (itʼs
coming)
• Low consistency with asynchronous
replication
5
Cassandra ?
• Just right, perhaps. Letʼs see...
• Highly available
• Tuneable synchronous replication
• Scalable writes and reads
• Schema free (sort of)
• Lots of new mistakes to be made
6
Availability
• Row data is kept together and
replicated around the cluster
• Replication Factor is configurable
• Partitioner determines the position of a
row key in the distributed hash table
• Replication Strategy determines where
in the cluster to place the replicas
7
Consistency
• Each read or write request specifies a
Consistency Level
• Individual nodes may be inconsistent with
respect to others
• Reads may give consistent results while some
nodes have inconsistent values
• The entire cluster will eventually mode to a
state where there is one version of each
8
Consistency
• R + W > N
• R = Read Consistency
• W = Write Consistency
• N = Replication Factor
9
Scale
• Distributed hash table
• Scale throughput and capacity with
more nodes, more disk, more memory
• Adding or removing nodes is an
online operation
• Gossip based protocol for discovery
10
Data Model
• Column orientated
• Denormalise
• Cassandra in an index building
machine
• Simple explanation: a row has a key
and stores an ordered hash in one or
more Column Families
11
Data Model
• Keyspace
• Row / Key
• Column Family or Super Column
Family
• Column
12
Data Model
User CF Posts SCF
Fred
email:fred@...
dob:04/03
post_1:{
title: foo,
body: bar}
Bob email:bob
post_100:{
title: monkeys,
body: naughty}
13
API
• Thrift
• Avro (beta)
• Auto generated bindings for many
languages
• Stateful connections
• Python wrappers pycassa, Telephus
(twisted)
14
API
• Client supplied time stamp for all
mutations
• Client supplied Consistency Level for
all mutations and reads
15
API
• insert (key, column_family,
super_column, column, value)
• get(key, column_family,
super_column, column)
• remove(key, column_family,
super_column, column)
16
API
• Slicing columns or super columns
• list of names
• start, finish, count, reversed
• get_slice() to slice one row
• multiget_slice() to slice multiple rows
• get_range_slices() to slice rows and
columns
17
API
• Slicing keys
• start key, finish key, count
• Partitioner effects key order
• get_range_slices() to slice rows and
columns
18
API
• batch_mutate()
• multiple rows and CFʼs
• delete or insert / update
• Individual mutations are atomic
• Request is not atomic, no rollback
19
Our Application
Varnish
Nginx
Tornado
Cassandra Rabbit MQ
20
Our Application
• Similar to Amazon S3.
• REST API.
• Databases, Buckets, Keys+Values.
21
Our Column Families
• Database (super)
• Bucket (super)
• Bucket Index
• Object
• Object Index (super)
22
Our API
http:// db_name.wetafx.co.nz/bucket/key
23
PUT Object
• /bucket/object
• batch_mutate()
• one row in Objects CF with columns
for meta and the body
• one column in ObjectIndex CF row
for the bucket
24
List Objects
• /bucket_name?start=foo
• get_slice()
• for the bucket row in ObjectIndex
CF
• if needed, multiget_slice() to “join”
to the Object CF
25
Delete Bucket
• /bucket_name
• get_slice() on ObjectIndex CF
• batch_mutate() to delete Object CF
and ObjectIndex CF
• delete Bucket CF row
26
Thanks
• http://wetafx.co.nz
• http://cassandra.apache.org/
•
27

More Related Content

PPTX
From a kafkaesque story to The Promised Land
PDF
Scylla Summit 2022: Operating at Monstrous Scales: Benchmarking Petabyte Work...
PDF
Building event streaming pipelines using Apache Pulsar
PDF
Stream processing using Apache Storm - Big Data Meetup Athens 2016
PDF
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...
PDF
A la rencontre de Kafka, le log distribué par Florian GARCIA
PDF
Presto at Twitter
PDF
Hail hydrate! from stream to lake using open source
From a kafkaesque story to The Promised Land
Scylla Summit 2022: Operating at Monstrous Scales: Benchmarking Petabyte Work...
Building event streaming pipelines using Apache Pulsar
Stream processing using Apache Storm - Big Data Meetup Athens 2016
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...
A la rencontre de Kafka, le log distribué par Florian GARCIA
Presto at Twitter
Hail hydrate! from stream to lake using open source

What's hot (20)

PDF
Kafka Summit SF 2017 - Real-Time Document Rankings with Kafka Streams
PPTX
Kafka & Hadoop - for NYC Kafka Meetup
PDF
Osacon 2021 hello hydrate! from stream to clickhouse with apache pulsar and...
PPTX
Bullet: A Real Time Data Query Engine
PDF
Scylla Summit 2022: Building Zeotap's Privacy Compliant Customer Data Platfor...
PDF
Kafka Summit NYC 2017 Introduction to Kafka Streams with a Real-life Example
PDF
Uber Real Time Data Analytics
PDF
Big data conference europe real-time streaming in any and all clouds, hybri...
PPTX
Matt Franklin - Apache Software (Geekfest)
PDF
Cracking the nut, solving edge ai with apache tools and frameworks
PDF
InfluxDB IOx Tech Talks: Replication, Durability and Subscriptions in InfluxD...
PDF
Standing Up Your First Cluster
PPT
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
PDF
Streaming process with Kafka Connect and Kafka Streams
PDF
Apache Pulsar and Github
PPTX
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetes at Scale – Real-time Ano...
PDF
Building Realtim Data Pipelines with Kafka Connect and Spark Streaming
PPTX
An evening with Jay Kreps; author of Apache Kafka, Samza, Voldemort & Azkaban.
PPTX
How Tencent Applies Apache Pulsar to Apache InLong - Pulsar Summit Asia 2021
PPTX
Architecture of a Kafka camus infrastructure
Kafka Summit SF 2017 - Real-Time Document Rankings with Kafka Streams
Kafka & Hadoop - for NYC Kafka Meetup
Osacon 2021 hello hydrate! from stream to clickhouse with apache pulsar and...
Bullet: A Real Time Data Query Engine
Scylla Summit 2022: Building Zeotap's Privacy Compliant Customer Data Platfor...
Kafka Summit NYC 2017 Introduction to Kafka Streams with a Real-life Example
Uber Real Time Data Analytics
Big data conference europe real-time streaming in any and all clouds, hybri...
Matt Franklin - Apache Software (Geekfest)
Cracking the nut, solving edge ai with apache tools and frameworks
InfluxDB IOx Tech Talks: Replication, Durability and Subscriptions in InfluxD...
Standing Up Your First Cluster
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Streaming process with Kafka Connect and Kafka Streams
Apache Pulsar and Github
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetes at Scale – Real-time Ano...
Building Realtim Data Pipelines with Kafka Connect and Spark Streaming
An evening with Jay Kreps; author of Apache Kafka, Samza, Voldemort & Azkaban.
How Tencent Applies Apache Pulsar to Apache InLong - Pulsar Summit Asia 2021
Architecture of a Kafka camus infrastructure
Ad

Viewers also liked (13)

PDF
Cassandra at NoSql Matters 2012
PDF
CQL Under the Hood
PDF
Real-time Cassandra
PPTX
Cassandra DataTables Using RESTful API
PDF
CQL3 in depth
PDF
A Shortcut to Awesome: Cassandra Data Modeling By Example (Jon Haddad, The La...
PDF
CassieQ: The Distributed Message Queue Built on Cassandra (Anton Kropp, Cural...
PPTX
High performance queues with Cassandra
PPTX
Understanding How CQL3 Maps to Cassandra's Internal Data Structure
PDF
Real-Time Analytics with Apache Cassandra and Apache Spark
KEY
Graphs in the Database: Rdbms In The Social Networks Age
PDF
Advanced data modeling with apache cassandra
KEY
Trees In The Database - Advanced data structures
Cassandra at NoSql Matters 2012
CQL Under the Hood
Real-time Cassandra
Cassandra DataTables Using RESTful API
CQL3 in depth
A Shortcut to Awesome: Cassandra Data Modeling By Example (Jon Haddad, The La...
CassieQ: The Distributed Message Queue Built on Cassandra (Anton Kropp, Cural...
High performance queues with Cassandra
Understanding How CQL3 Maps to Cassandra's Internal Data Structure
Real-Time Analytics with Apache Cassandra and Apache Spark
Graphs in the Database: Rdbms In The Social Networks Age
Advanced data modeling with apache cassandra
Trees In The Database - Advanced data structures
Ad

Similar to Building a distributed Key-Value store with Cassandra (20)

PDF
Outside The Box With Apache Cassnadra
PDF
The Cassandra Distributed Database
PDF
Spark Summit EU talk by Shay Nativ and Dvir Volk
PPTX
Vitalii Bondarenko - “Azure real-time analytics and kappa architecture with K...
KEY
KeyValue Stores
PPTX
HBase in Practice
PPTX
HBase in Practice
PDF
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
PDF
Training Slides: Basics 103: The Power of Tungsten Connector / Proxy
KEY
Why ruby and rails
PPTX
Scala and Spark are Ideal for Big Data
PPTX
Exploiting NoSQL Like Never Before
PDF
Clojure - An Introduction for Lisp Programmers
PPTX
Redis Labcamp
PPTX
Cassandra
PDF
JSR 335 / java 8 - update reference
PPTX
Cassandra for mission critical data
PDF
Spring one2gx2010 spring-nonrelational_data
KEY
Cassandra integrations
PDF
Your backend architecture is what matters slideshare
Outside The Box With Apache Cassnadra
The Cassandra Distributed Database
Spark Summit EU talk by Shay Nativ and Dvir Volk
Vitalii Bondarenko - “Azure real-time analytics and kappa architecture with K...
KeyValue Stores
HBase in Practice
HBase in Practice
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
Training Slides: Basics 103: The Power of Tungsten Connector / Proxy
Why ruby and rails
Scala and Spark are Ideal for Big Data
Exploiting NoSQL Like Never Before
Clojure - An Introduction for Lisp Programmers
Redis Labcamp
Cassandra
JSR 335 / java 8 - update reference
Cassandra for mission critical data
Spring one2gx2010 spring-nonrelational_data
Cassandra integrations
Your backend architecture is what matters slideshare

More from aaronmorton (20)

PDF
Cassandra South Bay Meetup - Backup And Restore For Apache Cassandra
PDF
Cassandra SF Meetup - CQL Performance With Apache Cassandra 3.X
PDF
Cassandra Day Atlanta 2016 - Monitoring Cassandra
PDF
Cassandra London March 2016 - Lightening talk - introduction to incremental ...
PDF
Cassandra SF 2015 - Repeatable, Scalable, Reliable, Observable Cassandra
PDF
Cassandra sf 2015 - Steady State Data Size With Compaction, Tombstones, and TTL
PDF
Cassandra TK 2014 - Large Nodes
PDF
Cassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break Glass
PDF
Cassandra Community Webinar - August 22 2013 - Cassandra Internals
PDF
Cassandra SF 2013 - In Case Of Emergency Break Glass
PDF
Cassandra SF 2013 - Cassandra Internals
PDF
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
PDF
Apache Cassandra in Bangalore - Cassandra Internals and Performance
PDF
Apache Con NA 2013 - Cassandra Internals
KEY
Cassandra SF 2012 - Technical Deep Dive: query performance
KEY
Hello @world #cassandra
KEY
Cassandra does what ? Code Mania 2012
PDF
Nzpug welly-cassandra-02-12-2010
PDF
Introduction to Cassandra
PDF
Cassandra - Wellington No Sql
Cassandra South Bay Meetup - Backup And Restore For Apache Cassandra
Cassandra SF Meetup - CQL Performance With Apache Cassandra 3.X
Cassandra Day Atlanta 2016 - Monitoring Cassandra
Cassandra London March 2016 - Lightening talk - introduction to incremental ...
Cassandra SF 2015 - Repeatable, Scalable, Reliable, Observable Cassandra
Cassandra sf 2015 - Steady State Data Size With Compaction, Tombstones, and TTL
Cassandra TK 2014 - Large Nodes
Cassandra Community Webinar August 29th 2013 - In Case Of Emergency, Break Glass
Cassandra Community Webinar - August 22 2013 - Cassandra Internals
Cassandra SF 2013 - In Case Of Emergency Break Glass
Cassandra SF 2013 - Cassandra Internals
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
Apache Cassandra in Bangalore - Cassandra Internals and Performance
Apache Con NA 2013 - Cassandra Internals
Cassandra SF 2012 - Technical Deep Dive: query performance
Hello @world #cassandra
Cassandra does what ? Code Mania 2012
Nzpug welly-cassandra-02-12-2010
Introduction to Cassandra
Cassandra - Wellington No Sql

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Monthly Chronicles - July 2025
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Approach and Philosophy of On baking technology
PPTX
Cloud computing and distributed systems.
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Modernizing your data center with Dell and AMD
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Monthly Chronicles - July 2025
The AUB Centre for AI in Media Proposal.docx
Approach and Philosophy of On baking technology
Cloud computing and distributed systems.
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
20250228 LYD VKU AI Blended-Learning.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation theory and applications.pdf
Modernizing your data center with Dell and AMD

Building a distributed Key-Value store with Cassandra

  • 1. Building a Key-Value Store with Cassandra Kiwi PyCon 2010 Aaron Morton @aaronmorton Weta Digital 1
  • 2. Why Cassandra? • Part of a larger project started earlier this year to build new systems for code running on the render farm of 35,000 cores • Larger project goals were Scalability, Reliability, Flexible Schema 2
  • 3. How about MySQL ? • It works. But... • Schema changes • Write redundancy • Query language mismatch • So went looking for the right tool for the job 3
  • 4. Redis ? • Fast, flexible. But... • Single core limit • Replication, but no cluster (itʼs coming) • Limited support options 4
  • 5. Couch DB ? • Schema free, scalable (sort of), redundant (sort of). But... • Single write thread limit • Replication, but no cluster (itʼs coming) • Low consistency with asynchronous replication 5
  • 6. Cassandra ? • Just right, perhaps. Letʼs see... • Highly available • Tuneable synchronous replication • Scalable writes and reads • Schema free (sort of) • Lots of new mistakes to be made 6
  • 7. Availability • Row data is kept together and replicated around the cluster • Replication Factor is configurable • Partitioner determines the position of a row key in the distributed hash table • Replication Strategy determines where in the cluster to place the replicas 7
  • 8. Consistency • Each read or write request specifies a Consistency Level • Individual nodes may be inconsistent with respect to others • Reads may give consistent results while some nodes have inconsistent values • The entire cluster will eventually mode to a state where there is one version of each 8
  • 9. Consistency • R + W > N • R = Read Consistency • W = Write Consistency • N = Replication Factor 9
  • 10. Scale • Distributed hash table • Scale throughput and capacity with more nodes, more disk, more memory • Adding or removing nodes is an online operation • Gossip based protocol for discovery 10
  • 11. Data Model • Column orientated • Denormalise • Cassandra in an index building machine • Simple explanation: a row has a key and stores an ordered hash in one or more Column Families 11
  • 12. Data Model • Keyspace • Row / Key • Column Family or Super Column Family • Column 12
  • 13. Data Model User CF Posts SCF Fred email:fred@... dob:04/03 post_1:{ title: foo, body: bar} Bob email:bob post_100:{ title: monkeys, body: naughty} 13
  • 14. API • Thrift • Avro (beta) • Auto generated bindings for many languages • Stateful connections • Python wrappers pycassa, Telephus (twisted) 14
  • 15. API • Client supplied time stamp for all mutations • Client supplied Consistency Level for all mutations and reads 15
  • 16. API • insert (key, column_family, super_column, column, value) • get(key, column_family, super_column, column) • remove(key, column_family, super_column, column) 16
  • 17. API • Slicing columns or super columns • list of names • start, finish, count, reversed • get_slice() to slice one row • multiget_slice() to slice multiple rows • get_range_slices() to slice rows and columns 17
  • 18. API • Slicing keys • start key, finish key, count • Partitioner effects key order • get_range_slices() to slice rows and columns 18
  • 19. API • batch_mutate() • multiple rows and CFʼs • delete or insert / update • Individual mutations are atomic • Request is not atomic, no rollback 19
  • 21. Our Application • Similar to Amazon S3. • REST API. • Databases, Buckets, Keys+Values. 21
  • 22. Our Column Families • Database (super) • Bucket (super) • Bucket Index • Object • Object Index (super) 22
  • 24. PUT Object • /bucket/object • batch_mutate() • one row in Objects CF with columns for meta and the body • one column in ObjectIndex CF row for the bucket 24
  • 25. List Objects • /bucket_name?start=foo • get_slice() • for the bucket row in ObjectIndex CF • if needed, multiget_slice() to “join” to the Object CF 25
  • 26. Delete Bucket • /bucket_name • get_slice() on ObjectIndex CF • batch_mutate() to delete Object CF and ObjectIndex CF • delete Bucket CF row 26