SlideShare a Scribd company logo
WHERETO PUT DATA
– or –
What are we going to do with all this stuff?
About The Speaker
Application Developer/Architect – 21 years
Web Developer – 15 years
Web Operations – 7 years
Relational
Shard
Replicate
Graph
Document
Key-value
Cache
Distributed
ACID
BASE
Cluster
Schema
Schemaless
Neo4J
Redis
Riak
Cassandra
Voldemort
NetStorage
S3
CloudFront
MongoDB
CouchDB
Memcached
Coherence
GridGain
BigMemory
HDFS
HBase
eXist
Xindice
BDB
BDB
Scalability Consistency
Relational Not Only SQL
Flexible Rigid
App Web Media Web API Gateway
CMSApp layer
Cache farm Search farm
Indexer
Search
Admin
Jobbers
Caching
Proxy/LB
Caching
Proxy/LB
CDN
Egress
ISP
Freshness
Response Time
Consistency
Resilience
Total Cost
Sustainability
Agility
BACK INTHE 90’S
BACK INTHE 90’S
BACK INTHE 90’S
OS 2200
Hierarchical ("Network") Database
OS 2200
Hierarchical ("Network") Database
Relational Mapper
OS 2200
Hierarchical ("Network") Database
Relational Mapper
POSIX.1 Virtual Machine
OS 2200
Hierarchical ("Network") Database
Relational Mapper
POSIX.1 Virtual Machine
COBOL Compiler
ANSI SQL Library
Given enough time, and
perversity, you can create any
query model on top of any
storage model.
SAY WHEN
The Importance of ResponseTime Distribution
FUNDAMENTAL PREMISE
Black Box
THERE ARETHINGSYOU
CANNOT KNOW
Will a response arrive?
When?
Was it stored or computed?
Is it still true?
ASYMMETRY OFTIME
Send
Request
Send
Request
100 ms 200 ms
ASYMMETRY OFTIME
Send
Request
100 ms 200 ms 300 ms 400 ms 500 ms 600 ms
ASYMMETRY OFTIME
Send
Request
100 ms 200 ms 300 ms 400 ms 500 ms 600 ms
Time
Out
ASYMMETRY OFTIME
9000 100 200 300 400 500 600 700 800
1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Time Elapsed (ms)
ConfidenceofResponsebeforeTimeout
Send
Request
100 ms 200 ms 300 ms 400 ms 500 ms 600 ms
Time
Out
Response
Arrives
ASYMMETRY OFTIME
To the observer, there is no
difference between “too slow” and
“not there”.
0%
6.25%
12.50%
18.75%
25.00%
0 100 200 300 400 500 600 700 800 900 1000
Response Time Histogram%ofResponses
Response Time (ms)
0%
6.25%
12.50%
18.75%
25.00%
0 100 200 300 400 500 600 700 800 900 1000
Response Time Histogram%ofResponses
Response Time (ms)
0%
6.25%
12.50%
18.75%
25.00%
0 100 200 300 400 500 600 700 800 900 1000
Response Time Histogram%ofResponses
Response Time (ms)
0%
25.00%
50.00%
75.00%
100.00%
0 100 200 300 400 500 600 700 800 900 ∞
Response Time Histogram%ofResponses
Response Time (ms)
This is a talk about data and
data storage.
scalability?
What about
Why am I talking so much about
observers and response time?
Why do we worry about
scalability?
Where to put_my_data
0%
25.00%
50.00%
75.00%
100.00%
0 100 200 300 400 500 600 700 800 900 1000
Response Time Histogram%ofResponses
Response Time (ms)
Empty Box Time
Response time of a
single request on an
unloaded system.
Scalability is a means, not an end.
What we need is
fast response time,
under all loads.
App Web Media Web API Gateway
CMSApp layer
Cache farm Search farm
Indexer
Search
Admin
Jobbers
Caching
Proxy/LB
Caching
Proxy/LB
CDN
Egress
HOWTRUE?
App Web Media Web API Gateway
CMSApp layer
Cache farm Search farm
Indexer
Search
Admin
Jobbers
Caching
Proxy/LB
Caching
Proxy/LB
CDN
Egress
App Web Media Web API Gateway
CMS
App layer
Cache farm Search farm
Indexer
Search
Admin
Jobbers
Caching
Proxy/LB
Caching
Proxy/LB
CDN
Egress
ISP
You cannot be sure the data is unchanged since your
observation, except by making another observation.
P(unch) = F(dC/dt, dt)
UNCERTAINTY PRINCIPLE
THE ROLE OF SURPRISE
Unlikely answers are often more interesting.
SAYS WHO?
Thoughts on Consistency
OBSERVABILITY
OBSERVABILITY
Steve
Brian
OBSERVABILITY
Left Right
OBSERVABILITY
Steve
Brian
# Steve Brian
1 R R
2 L R
3 R L
STATE SPACE
X1 = {L, R}
X2 = {L, R}
SUPER-OBSERVER
Has a view which dominates the views of all other observers.
SUPER-OBSERVER
There are no one-to-many mappings from the super-
observer’s states to any other observer’s states.
SUPER-OBSERVER
A super-observer is maximally present if it can discriminate
among the Cartesian product of all other observations.
Observer Set of States
Steve {L, R}
Brian {L, R}
Super-Observer {L → B, R → F} × {L, R}
OBSERVABILITY
# Steve Brian Super-Observer
1 R R {F, R}
2 L R {B, R}
3 R L {F, L}
PORKY PIG’S
WINDOW SHADE
If Porky Pig is looking at the window shade,
he always observes it to be down.
If he is looking away from the window shade,
it rolls up.
FIRST DIMENSION
X1 = {looking, not looking}
SECOND DIMENSION
X1 = {looking, not looking}
X2 = {shade open, shade closed}
FORBIDDEN STATES
X1 = {looking, not looking}
X2 = {shade open, shade closed}
STATE SPACE
Cartesian product of all possible sets of states.
Example
1,000,000 bytes of RAM
8 bits per byte
2 states per bit
8,000,000 dimensions with 2 values each
or
1,000,000 dimensions with 256 values each
STATE SPACE
10,000,000 rows in a table
20 columns
Whole database is a single point in a 200,000,000
dimensional space.
Changes to data are transforms of that point.
State over time is the trajectory of that point.
CONSISTENCY
Not every point in state space is allowed.
BLACK BOX HYPOTHESIS
BLACK BOX HYPOTHESIS
External observers can only ever ask for projections of the
state space, at defined points in time.
BLACK BOX HYPOTHESIS
State space trajectories may cross into forbidden states, as
long as those are not revealed to observers.
PROJECTION
X1 = {looking, not looking}
Is Porky looking at the window shade?
P1
P2
BLACK BOX HYPOTHESIS
Even two clustered machines have their own state spaces.
It’s impossible for either to be a superobserver.
OBSERVED CONSISTENCY
Sufficient to ensure that forbidden states cannot be observed.
DOES A SUPEROBSERVER EXIST?
Only if there is exactly one single-threaded CPU,
in exactly one computer.
CONSEQUENCES
Consistency doesn’t exist in most systems today.
Sometimes we can fake it.
Many times, it doesn’t really matter.
WHAT ABOUT CAP?
Consistency:
“...there must exist a total order on all operations such that
each operation looks as if it were completed at a single instant.”
Seth Gilbert and Nancy Lynch. 2002.
Brewer's conjecture and the feasibility of consistent, available,
partition-tolerant web services.
SIGACT News 33, 2 (June 2002), 51-59. DOI=10.1145/564585.564601
http://doi.acm.org/10.1145/564585.564601
WHAT ABOUT CAP?
Linearizability
Seth Gilbert and Nancy Lynch. 2002.
Brewer's conjecture and the feasibility of consistent, available,
partition-tolerant web services.
SIGACT News 33, 2 (June 2002), 51-59. DOI=10.1145/564585.564601
http://doi.acm.org/10.1145/564585.564601
The data base consists of entities which are
related in certain ways. These relationships are
best thought of as assertions about the data.
Examples of such assertions are:
“Names is an index forTelephone_numbers.”
“The value of Count_of_X gives the number of
employees in department X.”
The data base is said to be consistent if it satisfies
all its assertions. In some cases, the data base must
become temporarily inconsistent in order to
transform it to a new consistent state.
From "Granularity of Locks and Degrees of Consistency in a
Shared Data Base",
J.N. Gray, R.A. Lorie, G.R. Putzolu, I.L.Traiger, 1976
From "Granularity of Locks and Degrees of Consistency in a
Shared Data Base",
J.N. Gray, R.A. Lorie, G.R. Putzolu, I.L.Traiger, 1976
Consistency is a predicate C on entities and their
values.The predicate is generally not known to the
system but is embodied in the structure of the
transactions.
From "Transactions and Consistency in Distributed Database Systems",
I.L.Traiger, J.N. Gray, C.A. Galtieri, and B.G. Lindsay, 1982
“C” VERSUS “A”?
Response Time
Consistency
Resilience
See also: http://goo.gl/1Yv3
→ http://dbmsmusings.blogspot.com/2010/04/problems-with-cap-and-yahoos-little.html
WHAT’STHAT?
Data Models and Composability
DATA MODEL DEFINED
The system’s representation of the consistency predicate C.
LATENT MODEL
Implicit in the structure of application code.
EXPLICIT
Visible to storage engine or applications, expressed in
machine-readable form.
HOMOICONIC
Explicit, and available for expressions, computations,
and validation together with statements about the data
itself.
Non-uniform.
CHALLENGES
Non-uniform.
Layered.
CHALLENGES
Non-uniform.
Layered.
Confined.
CHALLENGES
Non-uniform.
Layered.
Confined.
Non-composable.
CHALLENGES
ENFORCING C
Must account for overlapping wavefronts of information.
There is no master clock.
Simultaneity is positional.
Make C explicit in the application, don’t rely on storage engine.
HOW LONG?
On Lifecycles and Lifespans
Where to put_my_data
Where to put_my_data
Where to put_my_data
Where to put_my_data
Where to put_my_data
Where to put_my_data
Where to put_my_data
Where to put_my_data
Where to put_my_data
DOWN WITHTHE IRON FIST
Throw out the DBAs
Throw out the schemas
Unstructured
Semi-structured
DOWN WITHTHE IRON FIST
Put the application in charge.
DOWN WITHTHE IRON FIST
but...
DIFFICULTIES
Application versions
Validating correct behavior
Capturing knowledge about that behavior
UGLYTRUTH
Data routinely outlives applications.
Response Time
Total Cost
Sustainability
Agility
WHERE NOW?
WHERETO PUTYOUR DATA?
Data exists everywhere.
WHERETO PUTYOUR DATA?
Nothing lasts forever.
WHERETO PUTYOUR DATA?
Understand freshness.
WHERETO PUTYOUR DATA?
Engineer a good response time
distribution.
WHERETO PUTYOUR DATA?
Select the consistency model you need.
WHERETO PUTYOUR DATA?
Be agile and adaptable.
WHERETO PUTYOUR DATA?
Make it sustainable.
Michael T. Nygard
michael.nygard@n6consulting.com
@mtnygard
© 2010 N6 Consulting, LLC.All Rights Reserved.

More Related Content

Where to put_my_data