Http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis from
Cassandra vs MongoDB vs couchdb vs redis vs Riak vs hbase vs membase vs neo4j
While SQL databases are insanely useful tools, their monopoly ~ 15 years is coming to an end. And it was just time: I can't even count the things that were forced into relational databases, but never really fitted them.
But the differences between nosql databases are much bigger than it ever was between onesql database and another. this means that it is a bigger responsibility onsoftware implements tsto choose the appropriate one for a project right at the beginning.
In this light, here is a comparison ofcassandra, MongoDB, couchdb, redis, Riak, membase, neo4j andhbase:
MongoDB
- Written in:C ++
- Main Point:Retains some friendly properties of SQL. (query, index)
- License:Agpl (Drivers: Apache)
- Protocol:Custom, binary (bson)
- Master/Slave replication (Auto failover with replica sets)
- Sharding built-in
- Queries are Javascript expressions
- Run arbitrary JavaScript Functions server-side
- Better update-in-place than couchdb
- Uses memory mapped files for data storage
- Performance over features
- Journaling (with -- journal) is best turned on
- On 32bit systems, limited ~ 2.5 GB
- An empty database takes up 192 MB
- Gridfs to store big data + metadata (not actually an FS)
- Has geospatial Indexing
Best used:If you need dynamic queries. if you prefer to define indexes, not map/reduce functions. if you need good performance on a big dB. if you wanted couchdb, but your data changes too much, filling up disks.
For example:For most things that you wowould do with MySQL or PostgreSQL, but having predefined columns really holds you back.
Riak (V1.0)
- Written in:Erlang & C, some Javascript
- Main Point:Fault Tolerance
- License:Apache
- Protocol:HTTP/rest or custom binary
- Tunable trade-offs for distribution and replication (n, R, W)
- Pre-and post-commit hooks in Javascript or Erlang, for validation and security.
- MAP/reduce in Javascript or Erlang
- Links & link walking: use it as a graph database
- Secondary indices: but only one at once
- Large Object support (Luwak)
- Comes in "Open Source" and "Enterprise" editions
- Full-text search, indexing, querying with Riak search server (Beta)
- In the process of migrating the storing backend from "bitcask" to Google's "leveldb"
- Masterless multi-Site Replication replication and SNMP monitoring are already cially licensed
Best used:If you want something Cassandra-like (Dynamo-like), but no way you're gonna deal with the bloat and complexity. if you need very good single-site scalability, availability and fault-tolerance, but you're ready to pay for multi-site replication.
For example:Point-of-sales data collection. factory control systems. Places where even seconds of downtime hurt. cocould be used as a well-Update-able web server.
Couchdb (v1.1.1)
- Written in:Erlang
- Main Point:DB consistency, consistency of use
- License:Apache
- Protocol:HTTP/rest
- Bi-directional (!) Replication,
- Continuous or ad-hoc,
- With conflict detection,
- Thus, master-master replication .(!)
- MVCC-write operations do not block reads
- Previous versions of statements are available
- Crash-only (reliable) Design
- Needs compacting from time to time
- Views: Embedded MAP/reduce
- Formatting views: Lists & shows
- Server-side document validation possible
- Authentication possible
- Real-time updates via _ changes (!)
- Attachment handling
- Thus, couchapps (standalone JS Apps)
- Jquery library sorted DED
Best used:For accumulating, occasionally changing data, on which pre-defined queries are to be run. Places where Versioning is important.
For example:CRM, CMS systems. Master-master replication is an especially interesting feature, allowing easy multi-site deployments.
Redis (v2.4)
- Written in:C/C ++
- Main Point:Blazing fast
- License:BSD
- Protocol:Telnet-like
- Disk-backed in-memory database,
- Currently without disk-swap (Vm and diskstore were abandoned)
- Master-slave Replication
- Simple values or hash tables by keys,
- But complex operations like zrevrangebyscore.
- Incr & Co (good for Rate limiting or statistics)
- Has sets (also Union/diff/Inter)
- Has lists (also a queue; blocking pop)
- Has hashes (Objects of multiple fields)
- Sorted sets (high score table, good for range queries)
- Redis has transactions (!)
- Values can be set to expire (as in a cache)
- Pub/sub lets one implement messaging (!)
Best used:For rapidly changing data with a foreseeable database size (shocould fit mostly in memory ).
For example:Stock prices. analytics. Real-time Data Collection. Real-time communication.
Hbase (v0.92.0)
- Written in:Java
- Main Point:Billions of rows x millions of Columns
- License:Apache
- Protocol:HTTP/rest (also thrift)
- Modeled after Google's bigtable
- Uses hadoop's HDFS as storage
- MAP/reduce with hadoop
- Query predicate push down via server side scan and get Filters
- Optimizations for real time queries
- A high performance thrift Gateway
- HTTP supports XML, protobuf, and binary
- Cascading, hive, and pig Source and Sink modules
- Jruby-based (jirb) Shell
- Rolling Restart for configuration changes and minor upgrades
- Random Access performance is like MySQL
- A cluster consists of several different types of nodes
Best used:Hadoop is probably still the best way to run MAP/reduce jobs on huge datasets. Best if you use the hadoop/HDFS stack already.
For example:Analysing log data.
Neo4j (v1.5m02)
- Written in:Java
- Main Point:Graph database-connected data
- License:GPL, some features agpl/commercial
- Protocol:HTTP/rest (or embedding in Java)
- Standalone, or embeddable into Java applications
- Full acid conformity (including durable data)
- Both nodes and relationships can have metadata
- Integrated pattern-matching-Based Query Language ("Cypher ")
- Also the "gremlin" Graph traversal language can be used
- Indexing of nodes and relationships
- Nice self-contained Web Admin
- Advanced Path-finding with multiple algorithms
- Indexing of keys and relationships
- Optimized for reads
- Has transactions (in the Java API)
- Scriptable in groovy
- Online backup, advanced monitoring and high availability is agpl/commercial licensed
Best used:For graph-style, rich or complex, interconnected data. neo4j is quite different from the others in this sense.
For example:Social relations, public transport links, road maps, network topologies.
Cassandra
- Written in:Java
- Main Point:Best of bigtable and Dynamo
- License:Apache
- Protocol:Custom, binary (thrift)
- Tunable trade-offs for distribution and replication (n, R, W)
- Querying by column, range of keys
- Bigtable-like features: columns, column families
- Has secondary indices
- Writes are much faster than reads (!)
- MAP/reduce possible with Apache hadoop
- All nodes are similar, as opposed to hadoop/hbase
Best used:When you write more than you read (logging). If every component of the system must be in Java. ("no one gets fired for choosing Apache's stuff .")
For example:Banking, Financial Industry (though not necessarily for financial transactions, but these industries are much bigger than that.) writes are faster than reads, so one natural niche is real time data analysis.
Membase
- Written in:Erlang & C
- Main Point:Memcache compatible, but with persistence and clustering
- License:In Apache 2.0
- Protocol:Memcached plus extensions
- Very fast (200 K +/sec) Access of data by key
- Persistence to disk
- All nodes are identical (master-master replication)
- Provides memcached-style in-memory caching buckets, too
- Write de-duplication to reduce Io
- Very nice cluster-management web GUI
- Software upgrades without taking the DB offline
- Connection proxy for Connection Pooling and multiplexing (Moxi)
Best used:Any application where low-latency data access, high concurrency support and high availability is a requirement.
For example:Low-latency use-cases like ad targeting or highly-concurrent web apps like online gaming (e.g. Zynga ).
Of course, all systems have much more features than what's listed here. I only wanted to list the key points that I base my decisions on. also, development of all are very fast, so things are bound to change. i'll do my best to keep this list updated.
-- Kristof