









Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!










Originally published in 2010, last revised December 2011
In this paper, we examine a number of SQL and so- called “NoSQL” data stores designed to scale simple OLTP-style application loads over many servers. Originally motivated by Web 2.0 applications, these systems are designed to scale to thousands or millions of users doing updates as well as reads, in contrast to traditional DBMSs and data warehouses. We contrast the new systems on their data model, consistency mechanisms, storage mechanisms, durability guarantees, availability, query support, and other dimensions. These systems typically sacrifice some of these dimensions, e.g. database-wide transaction consistency, in order to achieve others, e.g. higher availability and scalability. Note: Bibliographic references for systems are not listed, but URLs for more information can be found in the System References table at the end of this paper. Caveat: Statements in this paper are based on sources and documentation that may not be reliable, and the systems described are “moving targets,” so some statements may be incorrect. Verify through other sources before depending on information here. Nevertheless, we hope this comprehensive survey is useful! Check for future corrections on the author’s web site cattell.net/datastores. Disclosure: The author is on the technical advisory board of Schooner Technologies and has a consulting business advising on scalable databases.
In recent years a number of new systems have been designed to provide good horizontal scalability for simple read/write database operations distributed over many servers. In contrast, traditional database products have comparatively little or no ability to scale horizontally on these applications. This paper examines and compares the various new systems. Many of the new systems are referred to as “NoSQL” data stores. The definition of NoSQL, which stands for “Not Only SQL” or “Not Relational”, is not entirely agreed upon. For the purposes of this paper, NoSQL systems generally have six key features:
However, the systems differ in how much they give up. For example, most of the systems call themselves “eventually consistent”, meaning that updates are eventually propagated to all nodes, but many of them provide mechanisms for some degree of consistency, such as multi-version concurrency control (MVCC). Proponents of NoSQL often cite Eric Brewer’s CAP theorem [4], which states that a system can have only two out of three of the following properties: consistency, availability, and partition-tolerance. The NoSQL systems generally give up consistency. However, the trade-offs are complex, as we will see. New relational DBMSs have also been introduced to provide better horizontal scaling for OLTP, when compared to traditional RDBMSs. After examining the NoSQL systems, we will look at these SQL systems and compare the strengths of the approaches. The SQL systems strive to provide horizontal scalability without abandoning SQL and ACID transactions. We will discuss the trade-offs here. In this paper, we will refer to both the new SQL and NoSQL systems as data stores , since the term “database system” is widely used to refer to traditional DBMSs. However, we will still use the term “database” to refer to the stored data in these systems. All of the data stores have some administrative unit that you would call a database: data may be stored in one file, or in a directory, or via some other mechanism that defines the scope of data used by a group of applications. Each database is an island unto itself, even if the database is partitioned and distributed over multiple machines: there is no “federated database” concept in these systems (as with some relational and object-oriented databases), allowing multiple separately-administered databases to appear as one. Most of the systems allow horizontal partitioning of data, storing records on different servers according to some key; this is called “sharding”. Some of the systems also allow vertical partitioning, where parts of a single record are stored on different servers.
Before proceeding, some clarification is needed in defining “horizontal scalability” and “simple operations”. These define the focus of this paper. By “simple operations”, we refer to key lookups, reads and writes of one record or a small number of records. This is in contrast to complex queries or joins, read- mostly access, or other application loads. With the advent of the web, especially Web 2.0 sites where millions of users may both read and write data, scalability for simple database operations has become more important. For example, applications may search and update multi-server databases of electronic mail, personal profiles, web postings, wikis, customer records, online dating records, classified ads, and many other kinds of data. These all generally fit the definition of “simple operation” applications: reading or writing a small number of related records in each operation. The term “horizontal scalability” means the ability to distribute both the data and the load of these simple operations over many servers, with no RAM or disk shared among the servers. Horizontal scaling differs from “vertical” scaling, where a database system utilizes many cores and/or CPUs that share RAM and disks. Some of the systems we describe provide both vertical and horizontal scalability, and the effective use of multiple cores is important, but our main focus is on horizontal scalability, because the number of cores that can share memory is limited, and horizontal scaling generally proves less expensive, using commodity servers. Note that horizontal and vertical partitioning are not related to horizontal and vertical scaling , except that they are both useful for horizontal scaling.
Some authors have used a broad definition of NoSQL, including any database system that is not relational. Specifically, they include:
Voldemort can store data in RAM, but it also permits plugging in a storage engine. In particular, it supports a Berkeley DB and Random Access File storage engine. Voldemort supports lists and records in addition to simple scalar values.
Riak is written in Erlang. It was open-sourced by Basho in mid-2009. Basho alternately describes Riak as a “key-value store” and “document store”. We will categorize it as an advanced key-value store here, because it lacks important features of document stores, but it (and Voldemort) have more functionality than the other key-value stores:
The Redis key-value data store started as a one-person project but now has multiple contributors as BSD- licensed open source. It is written in C. A Redis server is accessed by a wire protocol implemented in various client libraries (which must be updated when the protocol changes). The client side does the distributed hashing over servers. The servers store data in RAM, but data can be copied to disk for backup or system shutdown. System shutdown may be needed to add more nodes. Like the other key-value stores, Redis implements insert, delete and lookup operations. Like Voldemort, it allows lists and sets to be associated with a key, not just a blob or string. It also includes list and set operations. Redis does atomic updates by locking, and does asynchronous replication. It is reported to support about 100K gets/sets per second on an 8-core server.
Scalaris is functionally similar to Redis. It was written in Erlang at the Zuse Institute in Berlin, and is open source. In distributing data over nodes, it allows key ranges to be assigned to nodes, rather than simply hashing to nodes. This means that a query on a range of values does not need to go to every node, and it also may allow better load balancing, depending on key distribution.
Like the other key-value stores, it supports insert, delete, and lookup. It does replication synchronously (copies must be updated before the operation is complete) so data is guaranteed to be consistent. Scalaris also supports transactions with ACID properties on multiple objects. Data is stored in memory, but replication and recovery from node failures provides durability of the updates. Nevertheless, a multi-node power failure would cause disastrous loss of data, and the virtual memory limit sets a maximum database size. Scalaris reads and writes must go to a majority of the replicas before an operation completes. Scalaris uses a ring of nodes, an unusual distribution and replication strategy that requires log(N) hops to read/write a key- value pair.
Tokyo Cabinet / Tokyo Tyrant was a sourcefourge.net project, but is now licensed and maintained by FAL Labs. Tokyo Cabinet is the back-end server, Tokyo Tyrant is a client library for remote access. Both are written in C. There are six different variations for the Tokyo Cabinet server: hash indexes in memory or on disk, B- trees in memory or on disk, fixed-size record tables, and variable-length record tables. The engines obviously differ in their performance characteristics, e.g. the fixed-length records allow quick lookups. There are slight variations on the API supported by these engines, but they all support common get/set/update operations. The documentation is a bit unclear, but they claim to support locking, ACID transactions, a binary array data type, and more complex update operations to atomically update a number or concatenate to a string. They support asynchronous replication with dual master or master/slave. Recovery of a failed node is manual, and there is no automatic sharding.
The memcached open-source distributed in-memory indexing system has been enhanced by Schooner Tehnologies and Membase, to include features analogous to the other key-value stores: persistence, replication, high availability, dynamic growth, backup, and so on. Without persistence or replication, memcached does not really qualify as a “data store”. However, Membrain and Membase certainly do, and these systems are also compatible with existing memcached applications. This compatibility is an attractive feature, given that memcached is widely used; memcached users that require more advanced features can easily upgrade to Membase and Membrain. The Membase system is open source, and is supported by the company Membase. Its most attractive feature is probably its ability to elastically add or remove servers in a running system, moving data and dynamically redirecting requests in the meantime. The elasticity in most of the other systems is not as convenient. Membrain is licensed per server, and is supported by Schooner Technologies. Its most attractive feature is probably its excellent tuning for flash memory. The performance gains of flash memory will not be gained in other systems by treating flash as a faster hard disk; it is important that the system treat flash as a true “third tier”, different from RAM and disk. For example, many systems have substantial overhead in buffering and caching hard disk pages; this is unnecessary overhead with flash. The benchmark results on Schooner’s web site show many times better performance than a number of competitors, particularly when data overflows RAM.
All the key-value stores support insert, delete, and lookup operations. All of these systems provide scalability through key distribution over nodes. Voldemort, Riak, Tokyo Cabinet, and enhanced memcached systems can store data in RAM or on disk, with storage add-ons. The others store data in RAM, and provide disk as backup, or rely on replication and recovery so that a backup is not needed. Scalaris and enhanced memcached systems use synchronous replication, the rest use asynchronous. Scalaris and Tokyo Cabinet implement transactions, while the others do not. Voldemort and Riak use multi-version concurrency control (MVCC), the others use locks. Membrain and Membase are built on the popular memcached system, adding persistence, replication, and other features. Backward compatibility with memcached give these products an advantage.
As discussed in the first section, document stores support more complex data than the key-value stores. The term “document store” may be confusing: while these systems could store “documents” in the traditional sense (articles, Microsoft Word files, etc.), a document in these systems can be any kind of “pointerless object”, consistent with our definition in Section 1. Unlike the key-value stores, these systems generally support secondary indexes and multiple types of documents (objects) per database, and nested documents or lists. Like other NoSQL systems, the
Another recent document store is Terrastore, which is built on the Terracotta distributed Java VM clustering product. Like many of the other NoSQL systems, client access to Terrastore is built on HTTP operations to fetch and store data. Java and Python client APIs have also been implemented. Terrastore automatically partitions data over server nodes, and can automatically redistribute data when servers are added or removed. Like MongoDB, it can perform queries based on a predicate, including range queries, and like CouchDB, it includes a map/reduce mechanism for more advanced selection and aggregation of data. Like the other document databases, Terrastore is schema-less, and does not provide ACID transactions. Like MongoDB, it provides consistency on a per- document basis: a read will always fetch the latest version of a document. Terrastore supports replication and failover to a hot standby.
The document stores are schema-less, except for attributes (which are simply a name, and are not pre- specified), collections (which are simply a grouping of documents), and the indexes defined on collections (explicitly defined, except with SimpleDB). There are some differences in their data models, e.g. SimpleDB does not allow nested documents. The document stores are very similar but use different terminology. For example, a SimpleDB Domain = CouchDB Database = MongoDB Collection = Terrastore Bucket. SimpleDB calls documents “items”, and an attribute is a field in CouchDB, or a key in MongoDB or Terrastore. Unlike the key-value stores, the document stores provide a mechanism to query collections based on multiple attribute value constraints. However, CouchDB does not support a non-procedural query language: it puts more work on the programmer and requires explicit utilization of indices. The document stores generally do not provide explicit locks, and have weaker concurrency and atomicity properties than traditional ACID-compliant databases.
They differ in how much concurrency control they do provide. Documents can be distributed over nodes in all of the systems, but scalability differs. All of the systems can achieve scalability by reading (potentially) out-of-date replicas. MongoDB and Terrastore can obtain scalability without that compromise, and can scale writes as well, through automatic sharding and atomic operations on documents. CouchDB might be able to achieve this write-scalability with the help of the new CouchDB Lounge code. A last-minute addendum as this paper goes to press: the CouchDB and and Membase companies have now merged, to form Couchbase. They plan to provide a “best of both” merge of their products, e.g. with CouchDB’s richer data model as well as the speed and elastic scalability of Membase. See Couchbase.com for more information.
The extensible record stores seem to have been motivated by Google’s success with BigTable. Their basic data model is rows and columns, and their basic scalability model is splitting both rows and columns over multiple nodes:
HBase is an Apache project written in Java. It is patterned directly after BigTable:
HyperTable is written in C++. Its was open-sourced by Zvents. It doesn’t seem to have taken off in popularity yet, but Baidu became a project sponsor, that should help. Hypertable is very similar to HBase and BigTable. It uses column families that can have any number of column “qualifiers”. It uses timestamps on data with MVCC. It requires an underyling distributed file system such as Hadoop, and a distributed lock manager. Tables are replicated and partitioned over servers by key ranges. Updates are done in memory and later flushed to disk.
when they span nodes. Scalable RDBMSs are therefore included as a viable alternative in this paper.
MySQL Cluster has been part of the MySQL release since 2004, and the code evolved from an even earlier project from Ericsson. MySQL Cluster works by replacing the InnoDB engine with a distributed layer called NDB. It is available from MySQL (now Oracle); it is open source. A proprietary MySQL Cluster Carrier Grade upgrade provides administrative and automated management functionality. MySQL Cluster shards data over multiple database servers (a “shared nothing” architecture). Every shard is replicated, to support recovery. Bi-directional geographic replication is also supported. MySQL Cluster supports in-memory as well as disk- based data. In-memory storage allows real-time responses. Although MySQL Cluster seems to scale to more nodes than other RDBMSs to date, it reportedly runs into bottlenecks after a few dozen nodes. Work continues on MySQL Cluster, so this is likely to improve.
VoltDB is a new open-source RDBMS designed for high performance (per node) as well as scalability. The scalability and availability features are competitive with MySQL Cluster and the NoSQL systems in this paper:
Clustrix offers a product with similarities to VoltDB and MySQL Cluster, but Clustrix nodes are sold as rack-mounted appliances. They claim scalability to hundreds of nodes, with automatic sharding and replication (with a 4:1 read/write ratio, they report 350K TPS on 20 nodes and 160M rows). Failover is automatic, and failed node recover is automatic. They also use solid state disks for additional performance (like the Schooner MySQL and NoSQL appliances). As with the other relational products, Clustrix supports SQL with fully-ACID transactions. Data distribution and load balancing is transparent to the application programmer. Interestingly, they also designed their system to be seamlessly compatible with MySQL, supporting existing MySQL applications and front-end connectors. This could give them a big advantage in gaining adoption of proprietary hardware.
ScaleDB is a new derivative of MySQL underway. Like MySQL Cluster, it replaces the InnoDB engine, and uses clustering of multiple servers to achieve scalability. ScaleDB differs in that it requires disks shared across nodes. Every server must have access to
every disk. This architecture has not scaled very well for Oracle RAC, however. ScaleDB’s sharding is automatic: more servers can be added at any time. Server failure handling is also automatic. ScaleDB redistributes the load over existing servers. ScaleDB supports ACID transactions and row-level locking. It has multi-table indexing (which is possible due to the shared disk).
ScaleBase takes a novel approach, seeking to achieve the horizontal scaling with a layer entirely on top of MySQL, instead of modifying MySQL. ScaleBase includes a partial SQL parser and optimizer that shards tables over multiple single-node MySQL databases. Limited information is available about this new system at the time of this writing, however. It is currently a beta release of a commercial product, not open source. Implementing sharding as a layer on top of MySQL introduces a problem, as transactions do not span MySQL databases. ScaleBase provides an option for distributed transaction coordination, but the higher- performance option provides ACID transactions only within a single shard/server.
NimbusDB is another new relational system. It uses MVCC and distributed object based storage. SQL is the access language, with a row-oriented query optimizer and AVL tree indexes. MVCC provides transaction isolation without the need for locks, allowing large scale parallel processing. Data is horizontally segmented row-by-row into distributed objects, allowing multi-site, dynamic distribution.
Google has recently created a layer on BigTable called Megastore. Megastore adds functionality that brings BigTable closer to a (scalable) relational DBMS in many ways: transactions that span nodes, a database schema defined in a SQL-like language, and hierarchical paths that allow some limited join capability. Google has also implemented a SQL processor that works on BigTable. There are still a lot of differences between Megastore / BigTable “NoSQL” and scalable relational systems, but the gap seems to be narrowing. Microsoft’s Azure Tables product provides horizontal scaling for both reads and writes, using a partition key, row key, and timestamps. Tables are stored “in the cloud” and can sync multiple databases. There is no fixed schema: rows consist of a list of property-value pairs. Due to the timing of the original version of this paper, Azure is not covered here. The major RDBMSs (DB2, Oracle, SQL Server) also include some horizontal scaling features, either shared- nothing, or shared-disk.
MySQL Cluster uses a “shared nothing” architecture for scalability, as with most of the other solutions in this section, and it is the most mature solution here. VoltDB looks promising because of its horizontal scaling as well as a bottom-up redesign to provide very high per-node performance. Clustrix looks promising as well, and supports solid state disks, but it is based on proprietary software and hardware. Limited information is available about ScaleDB, NimbusDB, and ScaleBase at this point; they are at an early stage. In theory, RDBMSs should be able to deliver scalability as long as applications avoid cross-node operations. If this proves true in practice, the simplicity of SQL and ACID transactions would give them an advantage over NoSQL for most applications.
No one of these data stores is best for all uses. A user’s prioritization of features will be different depending on the application, as will the type of scalability required. A complete guide to choosing a data store is beyond the scope of this paper, but in this section we look at some examples of applications that fit well with the different data store categories.
Key-value stores are generally good solutions if you have a simple application with only one kind of object, and you only need to look up objects up based on one attribute. The simple functionality of key-value stores may make them the simplest to use, especially if you’re already familiar with memcached. As an example, suppose you have a web application that does many RDBMS queries to create a tailored page when a user logs in. Suppose it takes several seconds to execute those queries, and the user’s data is rarely changed, or you know when it changes because updates go through the same interface. Then you might want to store the user’s tailored page as a single object in a key-value store, represented in a manner that’s efficient to send in response to browser requests, and index these objects by user ID. If you store these objects persistently, then you may be able to avoid many RDBMS queries, reconstructing the objects only when a user’s data is updated. Even in the case of an application like Facebook, where a user’s home page changes based on updates made by the user as well as updates made by others, it may be possible to execute RDBMS queries just once
Here are some predictions of what will happen with the systems we’ve discussed, over the next few years:
SQL (relational) versus NoSQL scalability is a controversial topic. This paper argues against both extremes. Here is some more background to support this position. The argument for relational over NoSQL goes something like this:
Given that scalability is the focus of this paper and of the systems we discuss, there is a “gaping hole” in our analysis: there is a scarcity of benchmarks to substantiate the many claims made for scalability. As we have noted, there are benchmark results reported on some of the systems, but almost none of the benchmarks are run on more than one system, and the results are generally reported by proponents of that one system, so there is always some question about their objectivity. In this paper, we’ve tried to make the best comparisons possible based on architectural arguments alone. However, it would be highly desirable to get some useful objective data comparing the architectures:
Given the quickly-changing landscape, this paper will not attempt to argue the merits of particular systems, beyond the comments already made. However, a comparison of the salient features may prove useful, so we finish with some comparisons. Table 1 below compares the concurrency control, data storage medium, replication, and transaction mechanisms of the systems. These are difficult to summarize in a short table entry without over- simplifying, but we compare as follows. For concurrency:
Dynamo Internal portal.acm.org/citation.cfm?id= 294281 GemFire Prop gemstone.com/products/gemfire HBase Apache hbase.apache.org HyperTable GPL hypertable.org Membase Apache membase.com Membrain Prop schoonerinfotech.com/products/ Memcached BSD memcached.org MongoDB GPL mongodb.org MySQL Cluster GPL mysql.com/cluster NimbusDB Prop nimbusdb.com Neo4j AGPL neo4j.org OrientDB Apache orienttechnologies.com PNUTs Internal research.yahoo.com/node/ Redis BSD code.google.com/p/redis Riak Apache riak.basho.com Scalaris Apache code.google.com/p/scalaris ScaleBase Prop scalebase.com ScaleDB GPL scaledb.com SimpleDB Prop amazon.com/simpledb Terrastore Apache code.google.com/terrastore Tokyo GPL tokyocabinet.sourceforge.net Versant Prop versant.com Voldemort None project-voldemort.com VoltDB GPL voltdb.com