Lecture10 Nosql PDF
Lecture10 Nosql PDF
NoSQL
Wednesday, December 1st, 2011
Discussion
• Repetitive record parsing: MR needs to
parse during both M and R.
• Compression in DBMS delivered
significant performance gain; unclear why
Hadoop MR did not benefit equally from
compression
• Pipelining
• Scheduling: static in DBMS (=query plan),
dynamic in MR
Dan Suciu -- CSEP544 Fall 2011 5
Stonebraker et al., CACM 2010
NoSQL
“Not Only SQL” or “Not Relational”.
Six key features:
1. Scale horizontally “simple operations”
2. Replicate/distribute data over many servers
3. Simple call level interface (contrast w/ SQL)
4. Weaker concurrency model than ACID
5. Efficient use of distributed indexes and RAM
6. Flexible schema
A Responsibility of B
Responsibility of C
C
D
Problem 1: Routing
A client doesn’t know server h(k), but some other server
Client
A only “knows”
server A
Redirect
request
to A + 2m
Found B
Read(k) !
to F + 1
G
C
to D + 2p
F O(log n)
E D
Problem 2: Joining
h=2n-1 h=0
When X joins:
select random ID
A
D C
Responsibility of D
Problem 2: Joining
h=2n-1 h=0
When X joins:
select random ID
A
D C
X Responsibility of D
Problem 2: Joining
h=2n-1 h=0
When X joins:
select random ID
A
Redistribute B
the load at D
D C
Responsibility of D X Responsibility of X
Problem 3: Replication
• Need to have some degree of replication
to cope with node failure
A Responsibility of B,C,D
Responsibility of C,D,E
C
D
Consistency
• ACID
– Two phase commit
– Paxos (will not discuss)
• Eventual consistency
– Vector clocks
• Standard MVCC:
each data item X has a timestamp t:
X4, X9, X10, X14, …, Xt
• Vector Clocks:
X has set of [server, timestamp] pairs
X([s1,t1], [s2,t2],…)
([SX,3],[SY,6]) ([SX,3],[SZ,2])
([SX,3]) ([SX,5])
([SX,3]) ([SX,5]) No
([SX,3]) ([SX,5]) No
([SX,3],[SY,6]) ([SX,3],[SY,6],[SZ,2])
([SX,3]) ([SX,5]) No
([SX,3],[SY,6]) ([SX,3],[SY,6],[SZ,2]) No
([SX,3]) ([SX,5]) No
([SX,3],[SY,6]) ([SX,3],[SY,6],[SZ,2]) No
([SX,3],[SY,10]) ([SX,3],[SY,6],[SZ,2])
([SX,3]) ([SX,5]) No
([SX,3],[SY,6]) ([SX,3],[SY,6],[SZ,2]) No
([SX,3]) ([SX,5]) No
([SX,3],[SY,6]) ([SX,3],[SY,6],[SZ,2]) No
([SX,3],[SY,10]) ([SX,3],[SY,20],[SZ,2])
([SX,3]) ([SX,5]) No
([SX,3],[SY,6]) ([SX,3],[SY,6],[SZ,2]) No
([SX,3],[SY,10]) ([SX,3],[SY,20],[SZ,2]) No
• Distributed databases
• Majority protocols
• DNS
• Web caching
Terminology
• Simple operations = key lookups, read/writes
of one record, or a small number of records
• Sharding = horizontal partitioning by some
key, and storing records on different servers
in order to improve performance.
• Horizontal scalability = distribute both data
and load over many servers Not exactly same as
horizontal partitioning
Data Model
• Tuple = row in a relational db
• Document = nested values, extensible
records (think XML or JSON)
• Extensible record = families of attributes
have a schema, but new attributes may be
added
• Object = like in a programming language,
but without methods
1. Key-value Stores
Think “file system” more than “database”
• Persistence,
• Replication
• Versioning,
• Locking
• Transactions
• Sorting
1. Key-value Stores
• Voldemort, Riak, Redis, Scalaris, Tokyo
Cabinet, Memcached/Membrain/Membase
2. Document Stores
• A "document" = a pointerless object = e.g.
JSON = nested or not = schema-less
2. Document Stores
• SimpleDB, CouchDB, MongoDB,
Terrastore
• Scalability:
– Replication (e.g. SimpleDB, CounchDB –
means entire db is replicated),
– Sharding (MongoDB);
– Both
Application 1
• Web application that needs to display lots
of customer information; the users data is
rarely updated, and when it is, you know
when it changes because updates go
through the same interface. Store this
information persistently using a KV store.
Key-value store
Application 2
• Department of Motor Vehicle: lookup
objects by multiple fields (driver's name,
license number, birth date, etc); "eventual
consistency" is ok, since updates are
usually performed at a single location.
Document Store
Application 3
• eBay stile application. Cluster customers
by country; separate the rarely changed
"core” customer information (address,
email) from frequently-updated info
(current bids).
Application 4
• Everything else (e.g. a serious DMV
application)
Scalable RDBMS
65
Aboulnaga’2011
66
Aboulnaga’2011
67
Aboulnaga’2011
3- v = read(k)
Data Center 3
68
Aboulnaga’2011
Criticism
• Two ways to improve OLTP performance:
– Sharding over shared-nothing
– Improve per-server OLTP performance
• Recent RDBMs do provide sharding:
Greenplum, Aster Data, Vertica, ParAccel
• Hence, the discussion is about single-
node performance
Criticism (cont’d)
• Single-node performance:
• Major performance bottleneck:
communication with DBMS using ODBC or
JDBC
– Solution: stored procedures, OR embedded
databases
• Server-side performance (next slide)
Criticism (cont’d)
Server-side performance: abut 25% each
• Logging
– Everything written twice; log must be forced
• Locking
– Needed for ACID semantics
• Latching
– This is when the DBMS itself is multithreaded;
e.g. latch for the lock table
• Buffer management
Dan Suciu -- CSEP544 Fall 2011 77
Stonebraker, CACM’2010 (blog 1)
Criticism (cont’d)
Main take-away:
• NoSQL databases give up 1, or 2, or 3 of
those features
• Thus, performance improvement can only
be modest
• Need to give up all 4 features for
significantly higher performance
• On the downside, NoSQL give up ACID
Dan Suciu -- CSEP544 Fall 2011 78
Stonebraker, CACM’2011 (blog 2)
Criticism (cont’d)
Who are the customers of NoSQL?
• Lots of startups
• Very few enterprises. Why? most
applications are traditional OLTP on
structured data; a few other applications
around the “edges”, but considered less
important
Criticism (cont’d)
• No ACID Equals No Interest
– Screwing up mission-critical data is no-no-no
• Low-level Query Language is Death
– Remember CODASYL?
• NoSQL means NoStandards
– One (typical) large enterprise has 10,000
databases. These need accepted standards