Even though SQL databases have always been the most useful tool in our IT industry, the "correction" that has been around for more than 15 years in the industry will finally end up. Now, although relational databases are still ubiquitous, they are increasingly unable to meet our needs. Nosql has become a new favorite in the industry.
However, the differences between various "nosql" databases are much larger than those between many relational databases in the past. This makes it more difficult for people to select the appropriate database to build their own applications.
In this summary PK, we compared Cassandra, MongoDB, couchdb, redis, Riak and hbase for reference:
Couchdb
-
- Written in:Erlang
-
- Main PointKey Points:DB consistencyConsistency, Usage of useEasy to use
-
- License Agreement:Apache
-
- Protocol:HTTP/rest
-
- Bi-directional (!) ReplicationBidirectional Replication,
-
- Continuous or ad-hoc,
- With Conflict DetectionConflict Detection,
-
- Thus, master-master replication .(!)Master-master Replication
-
- MVCC-write operations do not block readsWrite operations do not block read Operations
-
- Previous versions of statements are availableText Style
-
- Crash-only (reliable) DesignReliability Design
-
- Needs compacting from time to time
-
- Views: embeddedInternal embeddingMAP/reduceAlgorithm
-
- Formatting views: Lists & shows
-
- Server-side document validation possible
-
- Authentication possible
- Real-time updates via _ changes (!)Real-time update
-
- Attachment handling
-
- Thus, couchapps (standalone JS Apps)
-
- Jquery library sorted DED
Applicable: Accumulated computing, occasionally changing data, pre-defined queries, and version control considerations.
Example: CRM and CMS systems. Master-master replication is a special highlight and can be easily deployed on multiple sites.
Tutorial: http://guide.couchdb.org/editions/1/en/index.html
Redis
-
- Written in:C/C ++
-
- Main PointKey Points:Blazing fastUltra-fast
-
- License:BSD
-
- Protocol:Telnet-like
- Disk-backed in-memory database,Disk backup, Memory Database
-
- But since 2.0, it can swap to disk.But it is directly switched to the disk from 2.0.
-
- Master-slave ReplicationMaster-slave Replication
-
- Simple keys and values,Simple key-value format
-
- But complex operations like zrevrangebyscoreHowever, complex operations are similar to 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)
- Of all these databases, only redis does transactions (!)Among these databases, only redis hasTransactionsMechanism.
-
- Values can be set to expire (as in a cache)LikeCacheSimilarly, the value can be set to expire after a certain period of time.
-
- Sorted sets (high score table, good for range queries)Sorted sets, good at range query.
-
- Pub/sub and watch on data changes (!)The pub/sub and observer watch events are used to trigger data changes.
Applicable: When the database size is controllable (the entire memory is put down), the data can be changed quickly and the data can be written quickly.
Example: Stock price system analysis, real-time data collection, contact and so on.
MongoDB
-
- Written in:C ++
- Main Point:Retains some friendly properties of SQL.The SQL style is retained.(Query, index)
-
- License:Agpl (Drivers: Apache)
-
- Protocol:Custom, binary (bson)
-
- Master/Slave ReplicationMaster-slave replication (distributedClusterMethod)
-
- Queries are Javascript expressionsQuery is a javascript expression
-
- Run arbitrary JavaScript Functions server-side
-
- Better update-in-place than couchdbBetter local update than couchdb
-
- Sharding built-inBuilt-in Fragment
-
- Uses memory mapped files for data storageData Storage Using memory-Related Files
- Performance over features
-
- After crash, it needs to repair tablesAfter a crash, you need to repair the table.
Applicable: Dynamic query is required. you are willing to define the index indexes in advance without the map/reduce function. you need a huge database with good performance. You need couchdb, but your data changes frequently and requires frequent writing.
Example: Suitable for all MySQL or PostgreSQL scenarios.
Cassandra
- Written in:Java
- Main Point: Bigtable and Dynamo are the best big table models.
- License:Apache
- Protocol:Custom, binary (thrift)
- Tunable trade-offs for distribution and replication (n, R, W)
- Querying by column, range of keysQuery by Column
- Bigtable-like features: columns, column familiesColumn
- Writes are much faster than reads (!)Write faster than read
- MAP/reduce possible with Apache hadoop
- Some complexity may be caused by Java (such as configuration, seeing exceptions, etc)
Applicable: When there are more write operations than read operations (such as log logging ).
Example: Banking banking, financial system, writing must be faster than dual, real-time data analysis, etc.
Riak
- Written in:Erlang & C, some Javascript
- Main Point: Fault Tolerance Failure Recovery good reliability
- License:Apache
- Protocol:HTTP/rest
- Tunable trade-offs for distribution and replication (n, R, W)
- Pre-and post-commit hooks,
- For validation and security.
- Built-in full-text searchBuilt-in full text search
- MAP/reduce or Erlang in JavascriptSupported
- Comes in "Open Source" and "Enterprise" editionsThere are two versions
Applicable: If you want to have a style similar to Cassandra-like (Dynamo-like), but you don't want complexity and expansion of the processor. Good performance for a single serverScalabilityScalability, availability and fault tolerance fault-tolerance, adopt multi-site replication that is expensive.
Example: Point-of-sale data collection, factory control systems, and those that cannot be used in a matter of seconds.
Hbase
(With the help of ghshephard)
-
- Written in:Java
-
- Main Point: Billions of rows x millions of Columns with Large Capacity
-
- License:Apache
-
- Protocol:HTTP/rest (also thrift)
-
- Modeled after bigtableBig Table Model
-
- MAP/reduce with hadoopBuilt-in MAP/reduce
- Query predicate push down via server side scan and get Filters
-
- Optimizations for real time queriesReal-Time query-Based Optimization
-
- A high performance thrift GatewayHigh-performance thrift Gateway
-
- HTTP supports XML, protobuf, and binary
-
- Cascading, hive, and pig Source and Sink modules
-
- Jruby-based (jirb) Shell
-
- No single point of failureNo spof risks
-
- Rolling Restart for configuration changes and minor upgrades
-
- Random Access performance is like MySQLThe random access performance is similar to that of MySQL.
Applicable: If you like bigtable, you need random real-time read/write operations.
Example: Facebook message Database
Of course, all these database systems have much more features than listed here. I only list some key features based on my personal understanding here, and the development of these projects is also very active, I will try my best to keep it updated.
-- Kristof
Source: http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
Project name |
Language |
Fault Tolerance |
Persistent Storage Medium |
Client Protocol |
Data Model |
Document |
Sponsors/Community |
Project Voldemort |
Java |
Partition, copy, Read-repair |
Pluggable: berkleydb, MySQL |
Java API |
Structured/ Blob/Text |
A |
LinkedIn, no |
Ringo |
Erlang |
Partition, copy, Immutable |
Custom on-disk (Append only log) |
HTTP |
Blob |
B |
Nokia, no |
Scalaris |
Erlang |
Partition, copy, Paxos |
In-memory only |
Erlang, Java, HTTP |
Blob |
B |
Onscale, no |
Kai |
Erlang |
Partition, copy? |
On-disk dets File |
Memcached |
Blob |
C |
No |
Dynomite |
Erlang |
Partition, copy |
Pluggable: couch, Dets |
Custom ASCII, Thrift |
Blob |
D + |
Powerset, no |
Memcachedb |
C |
Copy |
Berkleydb |
Memcached |
Blob |
B |
Sina, some |
Thrudb |
C ++ |
Copy |
Pluggable: berkleydb, Custom, MySQL, S3 |
Thrift |
Document Oriented |
C + |
Third Rail, unsure |
Couchdb |
Erlang |
Copy, partition? |
Custom on-disk |
HTTP, JSON |
Document Oriented (JSON) |
A |
Apache, yes |
Cassandra |
Java |
Copy, partition |
Custom on-disk |
Thrift |
Bigtable meets Dynamo |
F |
Facebook, no |
Hbase |
Java |
Copy, partition |
Custom on-disk |
Custom API, Thrift, rest |
Bigtable |
A |
Apache, yes |
Hypertable |
C ++ |
Copy, partition |
Custom on-disk (HDFS, KFS) |
Thrift, Other |
Bigtable |
A |
Zvents, Baidu, yes |
Tokyo tyrant |
C |
Copy |
Tokyo Cabinet |
Memcached, HTTP, Other |
Blob |
A |
Mixi.jp, no |