Schemaless Databases


Published on

Overview of schemaless database technologies, from MUMPS to Mnesia.

Published in: Technology
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • This talk really comes out of my attempt to orient myself in this space. Background is in monitoring distributed systems, concerned with scalable collection and data analysis. But also want to know what I can use for semi-structured data “in the small”.
  • Where it applies, the distinction between relatively fixed schemas and dynamic ones is more technically significant than what query syntax is used to access the data, as has been shown by a number of products that provided a dialect of SQL as an alternative query language either alongside or on top of their native syntax.
  • PICK -- MultiValue (aka PICK) databases are developed at TRW in 1965. M[umps] -- According to comment from Scott Jones M[umps] is developed at Mass General Hospital in 1966. It is a programming language that incorporates a hierarchical database with B+ tree storage. IBM IMS -- IBM IMS, a hierarchical database, is developed with Rockwell and Caterpillar for the Apollo space program in 1966. ISM -- InterSystems develops the ISM product family succeeded by the Open M product, all M[umps] implementations. See comment from Scott Jones below. ANSI M -- M[umps] is approved as a ANSI standard language in 1977. AT&T DBM -- in 1979 Ken Thompson creates DBM which is released by AT&T. At it's core it is a file-based hash. TDBM -- TDBM supporting atomic transactions NDBM -- NDBM was the Berkeley version of DBM supporting having multiple databases open at the same time. SDBM -- SDBM - another clone of DBM mainly for licensing reasons. GT.M -- GT.M is the first version of a key-value store with focus on high performance transaction processing. It is open sourced in 2000. BerkeleyDB -- BerkeleyDB is created at Berkeley in the transition from 4.3BSD to 4.4BSD. Sleepycat software is started as a company in 1996 when Netscape needed new features for BerkeleyDB. Later acquired by Oracle which still sell and maintain BerkeleyDB. Lotus Domino -- Lotus Notes or rather the server part, Lotus Domino, which really is a document database has it's initial release in 1989, now sold by IBM. It has evolved a lot from the early versions and is now a full office and collaboration suite. GDBM -- GDBM is the Gnu project clone of DBM Mnesia -- Mnesia is developed by Ericsson as a soft real-time database to be used in telecom. It is relational in nature but does not use SQL as query language but rather Erlang itself. Cache -- InterSystems CachÈ launched in 1997 and is a hybrid so-called post-relational database. It has object interfaces, SQL, PICK/MultiValue and direct manipulation of data structures. It is a M[umps] implementation. See Scott Jones comment below for more on the history of InterSystems Metakit -- Metakit is started in 1997 and is probably the first document oriented database. Supports smaller datasets than the ones in vogue nowadays. Neo4j -- Graph database Neo4j is started in 2000. db4o -- db4o an object database for java and .net is started in 2000 QDBM -- QDBM is a re-implementation of DBM with better performance by Mikio Hirabayashi. Memcached -- Memcached is started in 2003 by Danga to power Livejournal. Memcached isn't really a database since it's memory-only but there is soon a version with file storage called memcachedb. Infogrid graph DB -- Infogrid graph database is started as closed source in 2005, open sourced in 2008 CouchDB -- CouchDB is started in 2005 and provides a document database inspired by Lotus Notes. The project moves to the Apache Foundation in 2008. Google BigTable -- Google BigTable is started in 2004 and the research paper is released in 2006. JackRabbit -- JackRabbit is started in 2006 as an implementation of JSR 170 and 283. Tokyo Cabinet -- Tokyo Cabinet is a successor to QDBM by (Mikio Hirabayashi) started in 2006 Dynamo -- The research paper on Amazon Dynamo is released in 2007. MongoDB -- The document database MongoDB is started in 2007 as a part of a open source cloud computing stack and first standalone release in 2009. Cassandra -- Facebooks open sources the Cassandra project in 2008 Voldemort -- Project Voldemort is a replicated database with no single point-of-failure. Started in 2008. Dynomite -- Dynomite is a Dynamo clone written in Erlang. Terrastore -- Terrastore is a scalable elastic document store started in 2009 Redis -- Redis is persistent key-value store started in 2009 Riak -- Riak Another dynamo-inspired database started in 2009. HBase -- HBase is a BigTable clone for the Hadoop project while Hypertable is another BigTable type database also from 2009. Vertexdb -- Vertexdb another graph database is started in 2009 Term: NOSQL -- Eric Evans of Rackspace, a committer on the Cassandra project, introduces the term NoSQL often used in the sense of Not only SQL to describe the surge of new projects and products.
  • Both of these systems are still used. An open-source version of M, called GT.M, is available (since 2000). M is still used by the US Dept of Veterans Affairs, and also by Ameritrade (Cache’: 12B transactions a day), ING Direct, and others in the financial industry. The IBM IMS system is still very actively used today, in particular for the US Federal Reserve. According to Wikipedia, odds are good your ATM transaction hits an IMS database. Chinese banks have purchased IMS technology. IMS includes a separate “transaction management” (TM) system.
  • E. F. Codd’s seminal 1970 paper, “ A Relational Model of Data for Large Shared Data Banks” laid out a solid mathematical basis for databases in contrast to the hierarchical and network models of the time, relational algebra, an offshoot of first-order logic, provided a declarative means of reasoning about the data that did not depend on the implementation SQL is “loosely based” on relational algebra
  • This taxonomy will be explored in more detail later, the point for now is that there are several different types of datastores and a number of examples of each and, referring back to the timeline, most of these implementations have occurred in the past few years..
  • Corporations (once again) found themselves at the forefront of systems research. But what was that research? (Read on..)
  • If nothing else, being able to refer to the “CAP theorem” the next time your networked demo breaks..
  • In his talk, Brewer said “there is almost no work in this area”. I think that the existence of scalable (schemaless) database systems is proof that this has changed.
  • Pictured is Parliament, pioneers of funk!
  • Trivia: what major movie was about producing a script called “Chubby Rain”?
  • Example of a BIgTable that stores web pages (directly out of the paper). The row names are reversed URLs (so sorted rows tend to group things by the same domain) There are two column families, “contents” and “anchor” In this example, each anchor cell has one version, and the contents column has 3
  • Paxos is an old and well-known algorithm. The Chubby “Database” is really a set of directories with small “lockfiles”. Each tablet server gets one Chubby directory, and each of its tablets is a lockfile.
  • These core services included the Amazon e-commerce shopping cart.
  • Each virtual node is responsible for keys between itself and its predecessor on the ring. The mapping of a single node to a variable number of virtual nodes on the hash ring accounts for heterogeneity (host “power”) in the system.
  • The quorum is “sloppy” because R and W refer to the number of healthy nodes, which may change between the write and subsequent read of the key.
  • (Who knows what this is?) The picture is a close-up of a vegetable: the “ Chou Romanesco" cauliflower
  • Particularly appropriate analogy because of the industry’s tendency to rush towards shiny new technologies! Following sections will examine each of these categories and walk through one publicly available product (or more) for each. With the exception of graph databases, which I simply haven’t taken the time to grok yet.
  • Both Voldemort and the next database, Riak, claim they were “inspired” by the early Dynamo paper
  • In the diagram, the green nodes are head; orange middle; red are tails. The white arrows are write requests, grey read requests, and red are (all) replies.
  • Developed by former engineers from BigTable and Dynamo projects, in heavy use at Facebook. For consistency level, zero = totally async.; Any= 1 node, including hinted handoff; Quorum = R/2+1 where R = #replicas Reads of 0 or Any don’t make sense. 0=no data, Any=wrong node; can’t do read-repairs, just the handed-off version
  • Has a nice Web UI called “Futon”. Yes, everything is a reclining furniture pun.
  • Obviously, this is at best a micro-benchmark. YCSB stands for Yahoo! Cloud Serving Benchmark
  • I won’t attempt to actually cover Map/Reduce, and don’t know Erlang. Instead: what impact do these databases have on data modeling efforts?
  • Schemaless Databases

    1. 1. Computational Research Division Lawrence Berkeley National Laboratory Dan Gunter
    2. 2. Introduction <ul><li>About this talk </li></ul><ul><ul><li>It is not “hands-on” (sorry) </li></ul></ul><ul><ul><li>Most of it is history and overview </li></ul></ul><ul><ul><li>It’s about databases, not explicitly “clouds” </li></ul></ul><ul><li>Relation to cloud computing </li></ul><ul><ul><li>Cloud computing and scalable databases go hand-in-hand </li></ul></ul><ul><ul><li>There are a lot of open-source NOSQL projects right now </li></ul></ul><ul><ul><li>Understanding what they do, and what features of the commercial implementations they’re imitating, gives insight into scalability issues for distributed computing in general </li></ul></ul>
    3. 3. Terminology: NOSQL and “Schemaless” <ul><li>First: not terribly important or deep in meaning </li></ul><ul><li>But “NOSQL” has gained currency </li></ul><ul><ul><li>Original, and best, meaning: Not Only SQL </li></ul></ul><ul><ul><ul><li>Wikipedia credits it to Carlo Strozzi in 1998, re-introduced in 2009 by Eric Evans of Rackspace </li></ul></ul></ul><ul><ul><ul><li>May use non-SQL, typically simpler, access methods </li></ul></ul></ul><ul><ul><ul><li>Don’t need to follow all the rules for RDBMS’es </li></ul></ul></ul><ul><ul><li>Lends itself to “No (use of) SQL”, but this is misleading </li></ul></ul><ul><li>Also referred to as “schemaless” databases </li></ul><ul><ul><li>Implies dynamic schema evolution </li></ul></ul>
    4. 4. NOSQL past and present Pre-RDBMS RDBMS era NOSQL
    5. 5. Pre-relational structured storage systems <ul><li>Hierarchical storage and sparse multi-dimensional arrays </li></ul><ul><li>MUMPS (Massachusetts General Hospital Utility Multi-Programming System), later ANSI M </li></ul><ul><ul><li>sparse multi-dimensional array </li></ul></ul><ul><ul><li>global variables, prefixed with “^”, are automatically persisted: </li></ul></ul><ul><li>^Car(“Door”,”Color”) = “Blue” </li></ul><ul><li>“ Pick” OS/database </li></ul><ul><ul><li>everything is hash table </li></ul></ul><ul><li>IBM Information Management System (IMS), [DB1] </li></ul>Computer Systems News , 11/28/83
    6. 6. The relational model <ul><li>Introduced with E. F. Codd’s 1970 paper “ A Relational Model of Data for Large Shared Data Banks” </li></ul><ul><li>Relational algebra provided declarative means of reasoning about data sets </li></ul><ul><li>SQL is loosely based on relational algebra </li></ul>A 1 ... A n Value 1 ... Value n R Relation (Table) Relation variable (Table name) Attribute (Column) {unordered} Heading Tuple (Row) {unordered}
    7. 7. Recent NOSQL database products Columnar or Extensible record Google BigTable HBase Cassandra HyperTable SimpleDB Document Store CouchDB MongoDB Lotus Domino Graph DB Neo4j FlockDB InfiniteGraph Key/Value Store Mnesia Memcached Redis Tokyo Cabinet Dynamo Project Voldemort Dynomite Riak
    8. 8. Why NOSQL? <ul><li>Renewed interest originated with global internet companies (Google, Amazon, Yahoo!, FaceBook, etc.) that hit limitations of standard RDBMS solutions for one or more of: </li></ul><ul><ul><li>Extremely high transaction rates </li></ul></ul><ul><ul><li>Dynamic analysis of huge volumes of data </li></ul></ul><ul><ul><li>Rapidly evolving and/or semi-structured data </li></ul></ul><ul><li>At the same time, these companies – unlike the financial and health services industries using M and friends – did not particularly need “ACID” transactional guarantees </li></ul><ul><ul><li>Didn’t want to run z/OS on mainframes </li></ul></ul><ul><ul><li>And had to deal with the ugly reality of distributed computing: networks break your $&#! </li></ul></ul>
    9. 9. CAP Theorem <ul><li>Introduced by Eric Brewer in a PODC keynote on July 2000, thus also known as “Brewer’s Theorem” </li></ul><ul><li>CAP = C onsistency, A vailability, P artition-tolerance </li></ul><ul><ul><li>Theorem states that in any “shared data” system, i.e. any distributed system, you can have at most 2 out of 3 of CAP (at the same time) </li></ul></ul><ul><ul><li>This was later proved formally (w/asynchronous model) </li></ul></ul><ul><li>Three possibilities: </li></ul>All robust distributed systems live here Forfeit partition-tolerance Forfeit availability Forfeit consistency Single-site databases, cluster databases, LDAP Distributed databases w/pessimistic locking, majority protocols Coda, web caching, DNS, Dynamo
    10. 10. CAP, ACID, and BASE <ul><li>RDBMS systems and research focus on ACID: A tomicity, C onsistency, I solation, and D urability </li></ul><ul><ul><li>concurrent operations act as if they are serialized </li></ul></ul><ul><li>Brewer’s point is that this is one end of a spectrum , one that sacrifices Partition-tolerance and Availability for Consistency </li></ul><ul><li>So, at the other end of the spectrum we have BASE : B asically A vailable S oft-state with E ventual consistency </li></ul><ul><ul><li>Stale data may be returned </li></ul></ul><ul><ul><li>Optimistic locking (e.g., versioned writes) </li></ul></ul><ul><ul><li>Simpler, faster, easier evolution </li></ul></ul>ACID BASE
    11. 11. Pioneers <ul><li>Google BigTable </li></ul><ul><li>Amazon Dynamo </li></ul>These implementations are not publicly available, but the distributed-system techniques that they integrated to build huge databases have been imitated, to a greater or lesser extent, by every implementation that followed.
    12. 12. Google BigTable <ul><li>Internal Google back-end, scaling to thousands of nodes, for </li></ul><ul><ul><li>web indexing, Google Earth, Google Finance </li></ul></ul><ul><li>Scales to petabytes of data, with highly varied data size & latency requirements </li></ul><ul><li>Data model is (3D) sparse, multi-dimensional, sorted map </li></ul><ul><ul><li>(row_key, column_key, timestamp) -> string </li></ul></ul><ul><li>Technologies: </li></ul><ul><ul><li>Google File System, to store data across 1000’s of nodes </li></ul></ul><ul><ul><ul><li>3-level indexing with Tablets </li></ul></ul></ul><ul><ul><li>SSTable for efficient lookup and high throughput </li></ul></ul><ul><ul><li>Distributed locking with Chubby </li></ul></ul>
    13. 13. BigTable’s Data Model Google’s Bigtable is essentially a massive, distributed 3-D spreadsheet. It doesn’t do SQL, there is limited support for atomic transactions, nor does it support the full relational database model. In short, in these and other areas, the Google team made design trade-offs to enable the scalability and fault-tolerance Google apps require. - Robin Harris, StorageMojo (blog), 2006-09-08 t 6 t 5 t 3 name contents: ... ... “ com.cnn.www” “ CNN” ... “” ... “ <html>...” “ <html>...” “ <html>...”
    14. 14. Tablets and SSTables <ul><li>Tablets represent contiguous groups of rows </li></ul><ul><ul><li>Automatically split when grow too big </li></ul></ul><ul><ul><li>One “tablet server” holds many tablets </li></ul></ul><ul><li>3-level indexing scheme similar to B+-tree </li></ul><ul><ul><li>Root tablet -> Metadata tablets -> Data (leaf) tablets </li></ul></ul><ul><ul><li>With 128MB metadata tablets, can addr. 2 34 leaves </li></ul></ul><ul><li>Client communicates directly with tablet server, so data does not go through root (i.e. locate, then transfer) </li></ul><ul><ul><li>Client also caches information </li></ul></ul><ul><li>Values written to memory, to disk in a commit log; periodically dumped into read-only SSTables . Better throughput at the expense of some latency </li></ul>
    15. 15. Use of Bloom Filters to optimize lookups <ul><li>Review: What is a Bloom filter? </li></ul><ul><ul><li>Can test whether an element is a member of a set </li></ul></ul><ul><ul><li>probabilistic: can only say “no” with certainty </li></ul></ul><ul><li>Here, tests if an SSTable has a row/column pair </li></ul><ul><ul><li>NO: Stop </li></ul></ul><ul><ul><li>YES: Need to load & retrieve data anyways </li></ul></ul><ul><li>Useful optimization in this space.. </li></ul>w is not in { x, y, z } because it hashes to one position with a 0 1 1 1 0 0 1 0 1 0 1 0 0 1 0 { x, w y, z }
    16. 16. Chubby and Paxos <ul><li>Chubby is a distributed locking service. Requests go the current Master. If the Master fails, Paxos is used to elect a new one </li></ul>Each “DB” is a replica Each server runs on its own host Google tends to run 5 servers, with only one being the “master” at any one time Chubby server DB Chubby server DB Chubby server DB Chubby server DB Chubby server DB Master
    17. 17. What about CAP? <ul><li>For bookkeeping tasks, Chubby’s replication allows tolerance of node failures ( P ) and consistency ( C ) at the price of availability ( A ), during time to elect a new master and synchronize the replicas. </li></ul><ul><li>Tablets have “relaxed consistency” of storage, GFS: </li></ul><ul><ul><li>A single master that maps files to servers </li></ul></ul><ul><ul><li>Multiple replicas of the data </li></ul></ul><ul><ul><li>Versioned writes </li></ul></ul><ul><ul><li>Checksums to detect corruption (with periodic handshakes) </li></ul></ul>
    18. 18. Amazon’s Dynamo <ul><li>Used by Amazon’s “core services”, for very high A and P at the price of C (“eventual consistency”) </li></ul><ul><li>Data is stored and retrieved solely by key (key/value store) </li></ul><ul><li>Techniques used: </li></ul><ul><ul><li>Consistent hashing – for partitioning </li></ul></ul><ul><ul><li>Vector clocks – to allow MVCC and read repairs rather than write contention </li></ul></ul><ul><ul><li>Merkle trees —a data structure that can diff large amounts of data quickly using a tree of hash values </li></ul></ul><ul><ul><li>Gossip – A decentralized information sharing approach that allows clusters to be self-maintaining </li></ul></ul><ul><li>Techniques not new, but their synthesis at this scale, in a real system, was </li></ul>
    19. 19. Dynamo data partitioning and replication Virtual node Host “node” Host “node” Virtual node Virtual node Virtual node Virtual node Virtual node Virtual node . . Hash ring using consistent hashing Host “node” Virtual node Virtual node Virtual node Virtual node 4 4 3 Item Hashes to this spot coordinator node replicas
    20. 20. Eventual consistency and sloppy quorum <ul><li>R = Number of healthy nodes from the preference list (roughly, list of “next” nodes on hash ring) needed for a read </li></ul><ul><li>W = Number of healthy nodes from preference list needed for a write </li></ul><ul><li>N = number of replicas of each data item </li></ul><ul><li>You can tune your performance </li></ul><ul><ul><li>R << N, high read availability </li></ul></ul><ul><ul><li>W << N, high write availability </li></ul></ul><ul><ul><li>R + W > N, consistent, but sloppy quorum </li></ul></ul><ul><ul><li>R + W < N, at best, eventual consistency </li></ul></ul><ul><li>Hinted handoff keeps track of the data “missed” by nodes that go down, and updates them when they come back online </li></ul>
    21. 21. Replica synchronization with Merkle trees <ul><li>When things go really bad, the “hinted” replicas may be lost and nodes may need to synchronize their replicas </li></ul><ul><li>To make synchronization efficient, all the keys for a given virtual node are stored in a hash tree or Merkle tree which stores data at the leaves and recursive hashes in the nodes </li></ul><ul><li>Same hash => Same data at leaves </li></ul>For Dynamo, the “data” are the keys stored in a given virtual node Each node is a hash of its children If two top hashes match, then the trees are the same
    22. 22. Infrastructure (at scale) is fractal <ul><li>This ability to be effective at multiple scales is crucial to the rise in NOSQL (schemaless) database popularity </li></ul><ul><li>Why didn’t Amazon or Google just run a big machine with something like GT.M, Vertica, or KDB (etc.)? </li></ul><ul><li>The answer must be partially to do something new, but partially that it wasn’t just shopping carts or search </li></ul>
    23. 23. The Gold Rush Columnar or Extensible record Google BigTable HBase Cassandra HyperTable SimpleDB Document Store CouchDB MongoDB Lotus Domino Graph DB Neo4j FlockDB InfiniteGraph Key/Value Store Mnesia Memcached Redis Tokyo Cabinet Dynamo Project Voldemort Dynomite Riak Hibari
    24. 24. <ul><li>Basic operations are simply get, put, and delete </li></ul><ul><li>All systems can distribute keys over nodes </li></ul><ul><li>Vector clocks are used as in Dynamo (or just locks) </li></ul><ul><li>Replication: common </li></ul><ul><li>Transactions: not common </li></ul><ul><li>Multiple storage engines: common </li></ul>Key/Value Store Memcached Redis Tokyo Cabinet Dynamo Project Voldemort Dynomite Riak Hibari
    25. 25. <ul><li>Dynamo-like features: </li></ul><ul><ul><li>Automatic partitioning with consistent hashing </li></ul></ul><ul><ul><li>MVCC with vector clocks </li></ul></ul><ul><ul><li>Eventual consistency (N, R, and W) </li></ul></ul><ul><li>Also: </li></ul><ul><ul><li>combines cache with storage to avoid sep. cache layer </li></ul></ul><ul><ul><li>pluggable storage layer </li></ul></ul><ul><ul><ul><li>RAM, disk, other.. </li></ul></ul></ul>Project Voldemort Type Key/Value Store License Apache 2.0 Language Java Company Linked-In Web
    26. 26. <ul><li>Dynamo-like features: </li></ul><ul><ul><li>Consistent hashing </li></ul></ul><ul><ul><li>MVCC with vector clocks </li></ul></ul><ul><ul><li>Eventual consistency (N, R, and W) </li></ul></ul><ul><li>Also: </li></ul><ul><ul><li>Hadoop-like M/R queries in either JS or Erlang </li></ul></ul><ul><ul><li>REST access API </li></ul></ul>result = self.client .add(bucket.get_name()) .map(&quot;Riak.mapValuesJson” .reduce(&quot;Riak.reduceSum” .run() Riak Example: Map/reduce with the Python API Type Key/Value Store License Open-Source Language Erlang Company Basho Web
    27. 27. <ul><li>Dynamo-like features: </li></ul><ul><ul><li>consistent hashing </li></ul></ul><ul><li>Unique features: </li></ul><ul><ul><li>Chain replication </li></ul></ul><ul><ul><ul><li>Each node may function as head, middle, or end of a chain associated with a position on the hash ring; head gets requests & tail services them. See </li></ul></ul></ul><ul><ul><li>Durability (fsync) in exchange for slower writes </li></ul></ul>Hibari Type Key/Value Store License Open-Source Language Erlang Company Gemini Mobile Web
    28. 28. <ul><li>All share BigTable data model </li></ul><ul><ul><li>rows and columns </li></ul></ul><ul><ul><li>“ column families” that can have new columns added </li></ul></ul><ul><li>Consistency models vary: </li></ul><ul><ul><li>MVCC </li></ul></ul><ul><ul><li>distributed locking </li></ul></ul><ul><li>Need to run on a different back-end than BigTable (GFS ain’t for sale) </li></ul>Columnar or Extensible record Google BigTable HBase Cassandra HyperTable
    29. 29. <ul><li>Marriage of BigTable and Dynamo </li></ul><ul><ul><li>Consistent hashing </li></ul></ul><ul><ul><li>Structured values </li></ul></ul><ul><ul><li>Columns / column families </li></ul></ul><ul><ul><li>Slicing with predicates </li></ul></ul><ul><ul><li>Tunable consistency: </li></ul></ul><ul><ul><ul><li>W = 0, Any, 1, Quorum, All </li></ul></ul></ul><ul><ul><ul><li>R = 1, Quorum, All </li></ul></ul></ul><ul><ul><li>Write commit log, memtable, and uses SSTables </li></ul></ul>Cassandra <ul><li>Used at: Facebook, Twitter, Digg, Reddit, Rackspace </li></ul>Type Extensible column store License Apache 2.0 Language Java Company Apache Software Foundation Web
    30. 30. <ul><li>Store objects (not really documents) </li></ul><ul><ul><li>think: nested maps </li></ul></ul><ul><li>Varying degrees of consistency, but not ACID </li></ul><ul><li>Allow queries on data contents (M/R or other) </li></ul><ul><li>May provide atomic read-and-set operations </li></ul>SimpleDB Document Store CouchDB MongoDB Lotus Domino Mnesia
    31. 31. <ul><li>Objects are grouped in “collections” </li></ul><ul><li>REST API </li></ul><ul><ul><li>not very efficient for throughput </li></ul></ul><ul><li>Read scalability through asynchronous replication with eventual consistency </li></ul><ul><li>No sharding </li></ul><ul><li>Incrementally updated M/R “views” </li></ul><ul><li>ACID? Uses MVCC and flush on commit. So, kinda.. </li></ul>CouchDB Type Document store License Apache 2.0 Language Erlang Company Apache Software Foundation Web
    32. 32. <ul><li>(Also) groups objects in “collections”, within a “database” </li></ul><ul><ul><li>Data stored in binary JSON called BSON </li></ul></ul><ul><li>Replication just for failover </li></ul><ul><li>Automatic sharding </li></ul><ul><li>M/R queries, and simple filters </li></ul><ul><li>User-defined indexes on fields of the objects </li></ul><ul><li>Atomic update “modifiers” can </li></ul><ul><ul><li>increment value </li></ul></ul><ul><ul><li>modify-if-current </li></ul></ul><ul><ul><li>..others </li></ul></ul>MongoDB <ul><li>As of v1.6, can also do limited replication with replica sets </li></ul> Type Document store License GPL Language C++ Company 10gen Web
    33. 33. <ul><li>Stores data in “tables” </li></ul><ul><ul><li>Data stored in memory </li></ul></ul><ul><ul><li>Logged to selected disks </li></ul></ul><ul><li>Replication and sharding </li></ul><ul><li>Queries are performed using Erlang list comprehensions (!) </li></ul><ul><li>User-defined indexes on fields of the objects </li></ul><ul><li>Transactions are supported (but optional) </li></ul><ul><li>Optimizing query compiler and dynamic “rule” tables </li></ul><ul><li>Embedded in Erlang OTP platform (similar to Pick ) </li></ul>Mnesia * Mozilla Public License modified to conform with laws of Sweden (more herring) Type Document store License EPL* Language Erlang Company Ericsson Web Papers
    34. 34. Why do we care about Mnesia / OTP? <ul><li>Database for RabbitMQ (distributed messaging behind S3) </li></ul><ul><li>Erlang seems to be gaining a popularity in the distributed-computing space </li></ul>females() -> F = fun() -> Q = query [ || E <- table(employee), = female] end, mnemosyne:eval(Q) end, mnesia:transaction(F). Erlang query for “all females” in company* *I know, but it’s not my example. This is right out of the manual.
    35. 35. Comparison of MongoDB and CouchDB <ul><li>Domain is monitoring a set of ongoing managed data transfers </li></ul><ul><ul><li>initial concern is handling the data in real-time </li></ul></ul><ul><li>So, did some very simple 1-node benchmarks of MongoDB and CouchDB load times (i.e on my laptop) for 200K records </li></ul><ul><li>Of course this is just one (lame) test </li></ul><ul><li>There is a need for a standard NOSQL benchmark suite; so far YCSB is the closest (from Yahoo!) </li></ul>Database Inserts/sec MongoDB 16,000 CouchDB 70 CouchDB, batch 1,800
    36. 36. Schemaless data modeling
    37. 37. Example from distributed monitoring <ul><li>Consider semi-structured input like: </li></ul><ul><li>ts=2010-02-20T23:14:06Z event=job.state level=Info wf_uuid=8bae72f2-31b9-45f4-bdd3-ce8032081a28 state=JOB_SUCCESS name=create_dir_montage_0_viz_glidein job_submit_seq=1 </li></ul><ul><li>If the fields are likely to change, or new types of data will appear, how to model this kind of data? </li></ul><ul><li>Blob </li></ul><ul><li>Placeholders </li></ul><ul><li>Entity-Attribute-Value </li></ul>All of these are data modeling “anti-patterns” for relational DBs
    38. 38. What’s wrong with EAV? <ul><li>It’s terrible, I should know, I tried it </li></ul><ul><li>You end up with queries that look like this to just extract a bunch of fields that started out in the same log line: </li></ul>
    39. 39. What about queries?
    40. 40. SQL vs. M/R and other models <ul><li>You need to think about this going in; you are throwing away much of the elegance of relational query optimization </li></ul><ul><ul><li>need to weigh against costs of static schemata </li></ul></ul><ul><li>Holistic approach: </li></ul><ul><ul><li>Spend lots of time on logical model, understand problem! </li></ul></ul><ul><ul><li>What degree of normalization makes sense? </li></ul></ul><ul><ul><li>Is your data well-represented as a hash table? Is it hierarchical? Graph-like? </li></ul></ul><ul><ul><li>What degree of consistency do you really need? Or maybe multiple ones? </li></ul></ul>
    41. 41. <ul><li>Google’s interactive analysis tool: Dremel </li></ul><ul><ul><li>see </li></ul></ul><ul><li>Uses a parallel “nested columnar storage” DB </li></ul><ul><li>SQL-like query language </li></ul><ul><ul><li>SELECT A, COUNT(B) FROM T GROUP BY A </li></ul></ul><ul><li>Interactive query times (seconds) on “trillions of records” </li></ul><ul><li>Of course it’s not released open-source, but the glove has been thrown </li></ul><ul><li>Now if we could only combine with visualization.. and link it all up to the cloud.. and make it free.. with ponies.. </li></ul>
    42. 42. Conclusions <ul><li>Anyone who says RDBMS is dead (and means it) is an idiot </li></ul><ul><li>SQL is mostly a red herring </li></ul><ul><ul><li>Can be layered on top of NOSQL, e.g. BigQuery and Hive </li></ul></ul><ul><li>What really is interesting about NOSQL is scalability (given relaxed consistency) and lack of static schemas </li></ul><ul><ul><li>incremental scalability from local disk to large degrees of parallelism in the face of distributed failure </li></ul></ul><ul><ul><li>easier schema evolution, esp. important at the “development” phase, which is often longer than anyone wants to admit </li></ul></ul><ul><li>Whether we should move towards the One True Database or a Unix-like ecosystem of tools is mostly a matter of philosophical bent; certainly both directions hold promise </li></ul>
    43. 43. Selected references <ul><li>Cattell’s overview of “scalable datastores” </li></ul><ul><ul><li> </li></ul></ul><ul><li>BigTable: </li></ul><ul><li>Stonebraker et al. on columnar vs. map/reduce </li></ul><ul><ul><li> </li></ul></ul><ul><li>NOSQL “summer reading”: </li></ul><ul><ul><li>“path throgh them”: </li></ul></ul><ul><li>Varley’s Master’s Thesis on non-relational db’s (modeling) </li></ul><ul><ul><li> </li></ul></ul>