the cassandra distributed database

40
The Cassandra Distributed Database Eric Evans [email protected] @jericevans FOSDEM February 7, 2010

Upload: eric-evans

Post on 08-Sep-2014

107.254 views

Category:

Technology


1 download

DESCRIPTION

Apache Cassandra is a highly scalable second-generation distributed database, bringing together Dynamo's fully distributed design and Bigtable's ColumnFamily-based data model. This presentation, given at FOSDEM in 2010, provides a brief summary of cassandra's history, a high-level overview of the architecture and data model, and showcases some real life use-cases.

TRANSCRIPT

Page 1: The Cassandra Distributed Database

The Cassandra Distributed Database

Eric [email protected]

@jericevans

FOSDEMFebruary 7, 2010

Page 2: The Cassandra Distributed Database

A prophetess in Troy during the Trojan War. Her predictions werealways true, but never believed.

Page 3: The Cassandra Distributed Database

A massively scalable, decentralized, structured data store (akadatabase).

Page 4: The Cassandra Distributed Database

Outline

1 Project History

2 Description

3 Case Studies

4 Roadmap

Page 5: The Cassandra Distributed Database
Page 6: The Cassandra Distributed Database
Page 7: The Cassandra Distributed Database
Page 8: The Cassandra Distributed Database

• 7 new committers added

• Dozens of contributors

• 100+ people on IRC

• Hundreds of closed issues (bugs, features, etc)

• 3 major releases, 2 point releases

• Graduation to TLP?

Page 9: The Cassandra Distributed Database

Outline

1 Project History

2 Description

3 Case Studies

4 Roadmap

Page 10: The Cassandra Distributed Database

Cassandra is...

• O(1) DHT

• Eventual consistency

• Tunable trade-offs, consistency vs. latency

Page 11: The Cassandra Distributed Database
Page 12: The Cassandra Distributed Database

But...

• Values are structured, indexed

• Columns / column families

• Slicing w/ predicates (queries)

Page 13: The Cassandra Distributed Database

Column families

Page 14: The Cassandra Distributed Database

Supercolumn families

Page 15: The Cassandra Distributed Database

Querying

• get(): retrieve by column name

• multiget(): by column name for a set of keys

• get slice(): by column name, or a range of names• returning columns• returning super columns

• multiget slice(): a subset of columns for a set of keys

• get count: number of columns or sub-columns

• get range slice(): subset of columns for a range of keys

Page 16: The Cassandra Distributed Database

Column comparators

• TimeUUID

• LexicalUUID

• UTF8

• Long

• Bytes

• ...

Page 17: The Cassandra Distributed Database

Updating

• insert(): add/update column (by key)

• batch insert(): add/update multiple columns (by key)

• remove(): remove a column

• batch mutate(): like batch insert() but can also delete(new for 0.6, deprecates batch insert())

• Remove key range RSN

Page 18: The Cassandra Distributed Database

Consistency

CAP Theorem: choose any two of Consistency, Availability, orPartition tolerance.

• Zero

• One

• Quorum ((N / 2) + 1)

• All

Page 19: The Cassandra Distributed Database

Client API

• Thrift (12 different languages!)

• Ruby• http://github.com/fauna/cassandra/tree/master• http://github.com/NZKoz/cassandra object/tree/master

• Python• http://github.com/digg/lazyboy/tree/master• http://github.com/driftx/Telephus/tree/master (Twisted)

• Scala• http://github.com/viktorklang/Cassidy/tree/master• http://github.com/nodeta/scalandra/tree/master

Page 20: The Cassandra Distributed Database

Performance vs MySQL w/ 50GB

• MySQL• 300ms write• 350ms read

• Cassandra• 0.12ms write• 15ms read

Page 21: The Cassandra Distributed Database

Writes

Page 22: The Cassandra Distributed Database

About writes...

• No reads

• No seeks

• Sequential disk access

• Atomic within a column family

• Fast

• Any node

• Always writeable (hinted hand-off)

Page 23: The Cassandra Distributed Database

Reads

Page 24: The Cassandra Distributed Database

About reads...

• Any node

• Read repair

• Usual caching conventions apply

Page 25: The Cassandra Distributed Database

Outline

1 Project History

2 Description

3 Case Studies

4 Roadmap

Page 26: The Cassandra Distributed Database

Case 1: Digg

Digg is a social news site that allows people to discover and sharecontent from anywhere on the Internet by submitting stories andlinks, and voting and commenting on submitted stories and links.

Ranked 98th by Alexa.com.

Page 27: The Cassandra Distributed Database

Digg

Page 28: The Cassandra Distributed Database

Problem

• Terabytes of data; high transaction rate (reads dominated)

• Multiple clusters; heavily sharded

• Management nightmare (high effort, error prone)

• Unsatisfied availability requirements (geographic isolation)

Page 29: The Cassandra Distributed Database

Solution

• Currently production on ”Green Badges”

• Cassandra as primary data store RSN

• Datacenter and rack-aware replication

Page 30: The Cassandra Distributed Database

Case 2: Twitter

Twitter is a social networking and microblogging service thatenables its users to send and read tweets, text-based posts of up to140 characters.

Ranked 12th by Alexa.com.

Page 31: The Cassandra Distributed Database

Twitter

Page 32: The Cassandra Distributed Database

MySQL

• Terabytes of data, ˜1,000,000 ops/s

• Calls for heavy sharding, light replication

• Schema changes are very difficult, (if possible at all)

• Manual sharding is very high effort

• Automated sharding and replication is Hard

Page 33: The Cassandra Distributed Database

Case 3: Facebook

Facebook is a social networking site where users can create aprofile, add friends, and send them messages. Users can also joingroups organized by location or other points of common interest.

Ranked #2 by Alexa.com.

Page 34: The Cassandra Distributed Database

Inbox Search

• 100 TB

• 160 nodes

• 1/2 billion writes per day (2yr old number?)

Page 35: The Cassandra Distributed Database

Case 4: Mahalo

Mahalo.com is a web directory and knowledge exchange. Itdifferentiates itself by tracking and building hand-crafted resultsets for many of the popular search terms.

(it also means ”thank you” in Hawaiian)

Page 36: The Cassandra Distributed Database

MySQL

• Partial deployment; 16 million video records (and growing)

• Writes (and storage) rapidly exceeding single box limitations

• Managability suffering (clustering is painful)

• Concerns over availability

Page 37: The Cassandra Distributed Database

Outline

1 Project History

2 Description

3 Case Studies

4 Roadmap

Page 38: The Cassandra Distributed Database

0.6

• batch mutate command

• authentication (basic)

• new consistency level, ANY

• fat client

• mmapped i/o reads (default on 64bit jvm)

• improved write concurrency (HH)

• networking optimizations

• row caching

• improved management tools

• per-keyspace replication factor

Page 39: The Cassandra Distributed Database

0.7

• more efficient compactions (row sizes bigger than memory)

• easier (dynamic?) column family changes

• SSTable versioning

• SSTable compression

• support for column family truncation

• improved configuration handling

• remove key range command

• even more improved management tools

• vector clocks w/ server-side conflict resolution

Page 40: The Cassandra Distributed Database

THE END