Database Reference
In-Depth Information
1.4.1
MongoDB versus other databases
The number of available databases has exploded, and weighing one against another
can be difficult. Fortunately, most of these databases fall under one of a few catego-
ries. In the sections that follow, I describe simple and sophisticated key-value stores,
relational databases, and document databases, and show how these compare and con-
trast with MongoDB.
Table 1.1
Database families
Examples
Data model
Scalability model
Use cases
Simple
key-value stores
Memcached
Key-value, where the
value is a binary blob.
Variable. Memcached
can scale across
nodes, converting all
available RAM into a
single, monolithic data
store.
Caching. Web ops.
Sophisticated
key-value stores
Cassandra,
Project Voldemort,
Riak
Variable. Cassandra
uses a key-value struc-
ture known as a col-
umn . Voldemort stores
binary blobs.
Eventually consistent,
multinode distribution
for high availability and
easy failover.
High throughput
verticals (activity
feeds, message
queues). Caching.
Web ops.
Relational
databases
Oracle database,
MySQL,
PostgreSQL
Ta b l e s .
Ver tical scaling. Lim-
ited support for cluster-
ing and manual
partitioning.
System requiring
transactions
(banking, finance)
or SQL. Normal-
ized data model.
S IMPLE KEY - VALUE STORES
Simple key-value stores do what their name implies: they index values based on a sup-
plied key. A common use case is caching. For instance, suppose you needed to cache
an HTML page rendered by your app. The key in this case might be the page's URL ,
and the value would be the rendered HTML itself. Note that as far as a key-value store
is concerned, the value is an opaque byte array. There's no enforced schema, as you'd
find in a relational database, nor is there any concept of data types. This naturally lim-
its the operations permitted by key-value stores: you can put a new value and then use
its key either to retrieve that value or delete it. Systems with such simplicity are gener-
ally fast and scalable.
The best-known simple key-value store is memcached (pronounced mem-cash-dee ).
Memcached stores its data in memory only, so it trades persistence for speed. It's also
distributed; memcached nodes running across multiple servers can act as a single data
store, eliminating the complexity of maintaining cache state across machines.
Compared with MongoDB, a simple key-value store like memcached will often
allow for faster reads and writes. But unlike MongoDB, these systems can rarely act as
primary data stores. Simple key-value stores are best used as adjuncts, either as
 
Search WWH ::




Custom Search