Cassandra Day Chicago 2015: Cassandra Consistency & Tolerance (A Morality Guide for Databases)
-
Upload
planet-cassandra -
Category
Technology
-
view
260 -
download
0
Transcript of Cassandra Day Chicago 2015: Cassandra Consistency & Tolerance (A Morality Guide for Databases)
Cassandra: Consistency & Tolerance (a morality guide for databases)Matt Kennedy, Architect
@thetweetofmatt
©2014 DataStax Confidential. Do not distribute without consent. 2
©2014 DataStax Confidential. Do not distribute without consent. 3
©2014 DataStax Confidential. Do not distribute without consent. 4
©2014 DataStax Confidential. Do not distribute without consent. 5
©2014 DataStax Confidential. Do not distribute without consent. 6
©2014 DataStax Confidential. Do not distribute without consent. 7
©2014 DataStax Confidential. Do not distribute without consent. 8
©2014 DataStax Confidential. Do not distribute without consent. 9
©2014 DataStax Confidential. Do not distribute without consent. 10
©2014 DataStax Confidential. Do not distribute without consent. 11
©2014 DataStax Confidential. Do not distribute without consent. 12
?
©2014 DataStax Confidential. Do not distribute without consent. 13
Georgetown
American
20 minutes
Worth the wait?
©2014 DataStax Confidential. Do not distribute without consent. 14
Georgetown
American
©2014 DataStax Confidential. Do not distribute without consent. 15
Lessons?
• High Availability means:• Have to maintain some redundancy• Need to distribute your stuff
• Distributed Stuff means:• Need to accommodate unreliable networks• Need to have strategies for different path costs• Plan for outright failures• Cooperation!
Also, don’t underestimate a squirrel with a Jesuit education.
©2014 DataStax Confidential. Do not distribute without consent. 16
©2014 DataStax Confidential. Do not distribute without consent. 17
©2014 DataStax Confidential. Do not distribute without consent. 18
Eventual Consistency
Meh.
©2014 DataStax Confidential. Do not distribute without consent. 19
http://nekrocodile-izumi.deviantart.com/art/Lazy-college-student-322186707
©2014 DataStax Confidential. Do not distribute without consent. 20
©2014 DataStax Confidential. Do not distribute without consent. 21
©2014 DataStax Confidential. Do not distribute without consent. 22
Consistency vs. Consistency
©2014 DataStax Confidential. Do not distribute without consent. 23
©2014 DataStax Confidential. Do not distribute without consent. 24
Tunable Consistency & High Availability
©2014 DataStax Confidential. Do not distribute without consent. 25
Example assumes replication factor = 3
write
read
Quorum-write, RF=5
©2014 DataStax Confidential. Do not distribute without consent. 26
Client
6-node cluster, rf=5 OK!
Quorum read RF=5
©2014 DataStax Confidential. Do not distribute without consent. 27
Client
6-node cluster, rf=5
00101010
00101010
00101010 00101010
? ?
Read value: 00101010
©2014 DataStax Confidential. Do not distribute without consent. 28
Linearizable Consistency
• AKA:• Compare & Set• Check & Set• Lightweight Transactions• CQL “IF” Statements
• Uses Paxos• Can specify local datacenter or all datacenters• (CASSANDRA-5797)
©2014 DataStax Confidential. Do not distribute without consent. 29
Linearizable Consistency
• Put X in the database if X is not already in the database
• Set foo=bar if foo=baz
• Set foo=bar if boo=faz
©2014 DataStax Confidential. Do not distribute without consent. 30
©2014 DataStax Confidential. Do not distribute without consent. 31
MONSTER MASH!!!
Alice Bob Create “Stinky”
C*
Create “Stinky”
Insert “Stinky” Insert “Stinky” Quorum insert
Quorum insert
Now Bob owns “Stinky” and Alice doesn’t know why she can’t see the monster she just made
©2014 DataStax Confidential. Do not distribute without consent. 32
MONSTER MASH!!!
Alice Bob Create “Stinky”
C*
Create “Stinky”
Insert “Stinky” Insert “Stinky”
LWT Insert LWT insert
NO!
Consistency & Cassandra
• Tunable Consistency
• Linearizable Consistency
• Your App can tell C* what it needs
©2014 DataStax Confidential. Do not distribute without consent. 33
THIS IS IMPORTANT
• The Consistency Mechanisms are King• Cassandra’s core strengths…• High Availability• Tolerance of node failures• Tolerance of datacenter failures• Tolerance of network failures between datacenters
• All due to the Consistency Mechanisms • Cassandra isn’t Cassandra without Eventual
Consistency
©2014 DataStax Confidential. Do not distribute without consent. 34
Consistency is a Key Value!
• Get it? Key-Value?• It’s a NoSQL joke.
• Always-on Big Data demands multi-region DCs• Multi-region DCs must face the reality of network partitions
• Eventual Consistency enables applications built on Cassandra to do what they need to do correctly and flexibly while remaining constantly available.
©2014 DataStax Confidential. Do not distribute without consent. 35
Thank You
©2014 DataStax Confidential. Do not distribute without consent.
Tunable Consistency & High Availability
©2014 DataStax Confidential. Do not distribute without consent. 37
write
read
Example assumes replication factor = 3
1.
2.
write
read
3.
Options 1 & 2 achieve strong consistency at the expense of availability. Option 3 requires only 2 replicas on write and 2 on read, so it achieves high availability & strong consistency.
Eventual Consistency The Netflix Experiment
• “Eventual Consistency != Hopeful Consistency”• Netflix, big C* user, performed an experiment
©2014 DataStax Confidential. Do not distribute without consent. 38
http://planetcassandra.org/blog/post/a-netflix-experiment-eventual-consistency-hopeful-consistency-by-christos-kalantzis/
©2014 DataStax Confidential. Do not distribute without consent. 39
C* Datacenters A Single Cluster
©2014 DataStax Confidential. Do not distribute without consent. 40
One Datacenter
Peer-to-peer ring of nodes
Datacenters can go offline…
©2014 DataStax Confidential. Do not distribute without consent. 41
For a variety of reasons
©2014 DataStax Confidential. Do not distribute without consent. 42
C* Datacenters A Single Cluster
©2014 DataStax Confidential. Do not distribute without consent. 43
One Datacenter
Peer-to-peer ring of nodes
C* Datacenters What happens when I lose one?
Los Angeles
©2014 DataStax Confidential. Do not distribute without consent. 44
Chicago
New York
C* Datacenters What is possible?
Los Angeles
©2014 DataStax Confidential. Do not distribute without consent. 45
Chicago
New York
Cloud
C* Datacenters Cloud Deployments
©2014 DataStax Confidential. Do not distribute without consent. 46
Availability Zone 1
AWS
C* Datacenters Cloud Deployments
©2014 DataStax Confidential. Do not distribute without consent. 47
Availability Zone 1
Availability Zone 2
AWS
C* Datacenters Cloud Deployments
©2014 DataStax Confidential. Do not distribute without consent. 48
Availability Zone 1
Availability Zone 2
Google Compute
Engine
AWS
C* Datacenters Cloud Deployments
©2014 DataStax Confidential. Do not distribute without consent. 49
Off-Cloud Migration
On-Prem
Start in Cloud