1、Mongodb,CouchDB為文檔型資料庫,可以了解為資料以JSON等文檔格式存儲;2、Cassandra,HBase為列簇型資料庫,同時支援更加複雜的存儲方式,是關系型資料庫擴充;3、Redis:提供了一組hash,set等資料結構,更像一組開發包。
參考資料:Cassandra,Mongodb,CouchDB,Redis,Riak,HBase比較
2012-02-04 22:02,已浏覽376次
盡管 SQL 資料庫一直是我們IT行業中最有用的工具,然而,它們這樣在行業中超過15年以上的“轉正”終于就要壽終正寝了。現在,雖然關系型資料庫仍然無所不在,但它越來越不能滿足我們的需要了。NoSQL成為了業界的新寵。
但是,各種 “NoSQL” 資料庫之間的差異比當年衆多關系型資料庫之間的差異要大許多。這就加大了人們在建設自己的應用是選擇合适的資料庫的難度。
在這篇彙總的PK中,我們對 Cassandra, Mongodb, CouchDB, Redis, Riak 和 HBase 進行了比較,以供參考:
CouchDB
* Written in: Erlang
* Main point關鍵點: DB consistency一緻性, ease 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 documents 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 included
适用: 累計 堆積計算, 偶爾改變資料, 預先定義的查詢. 非常注重版本控制的場合.
舉例: CRM, CMS系統. 主-主複制是其特别亮點,可以易于多個站點部署。
Redis
* Written in: C/C++
* Main point 關鍵點: Blazing fast 超快
* License: BSD
* Protocol: Telnet-like
* Disk-backed in-memory database, 磁盤後備,記憶體資料庫
* but since 2.0, it can swap to disk. 但是從2.0開始直接交換到磁盤
* Master-slave replication 主-從複制
* Simple keys and values, 簡單的key-value形式
* but complex operations like ZREVRANGEBYSCORE 但是複雜操作類似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 (!) 在這些資料庫中,隻有Redis有事務機制。
* Values can be set to expire (as in a cache) 如同緩存一樣,值能被設定為超過一定時間過期失效。
* Sorted sets (high score table, good for range queries) 有排序的sets,善于range查詢。
* Pub/Sub and WATCH on data changes (!) 采取Pub/Sub 和觀察者WATCH事件觸發資料變化。
适用: 在可以控制的資料庫大小情況下(放得下整個記憶體),快速改變資料,快速寫資料。
舉例: 股票價格系統 分析,實時資料收集,聯系等等。
MongoDB
* Written in: C++
* Main point: Retains some friendly properties of SQL. 保留類似SQL風格.(Query, index)
* License: AGPL (Drivers: Apache)
* Protocol: Custom, binary (BSON)
* Master/slave replication 主從複制(分布式狀态叢集方式)
* Queries are javascript expressions 查詢是javascript表達式
* Run arbitrary javascript functions server-side
* Better update-in-place than CouchDB 比CouchDB更好地就地更新
* Sharding built-in 内置分片碎片
* Uses memory mapped files for data storage 使用記憶體對應檔案方式實作資料存儲
* Performance over features
* After crash, it needs to repair tables 當崩潰後,需要修複表。
适用: 需要動态查詢. 願意事先定義索引indexes, 不需要 map/reduce 功能. 你需要巨大的資料庫有良好性能,你需要CouchDB但是你資料變化改變很頻繁,需要頻繁寫。
舉例: 适合所有MySQL 或者 PostgreSQL場合,它也适合
Cassandra
* Written in: Java
* Main point: 大表模型BigTable 和 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 列
* Writes are much faster than reads (!) 寫快于讀
* Map/reduce possible with Apache Hadoop
* 部分複雜性可能由于Java自身原因(如配置configuration, seeing exceptions, etc)
适用: 當寫操作多于讀操作 (如日志logging).
舉例: 銀行Banking, 金融系統,寫必須快于都的場合,實時的資料分析等.
Riak
* Written in: Erlang & C, some Javascript
* Main point: 容錯性Fault tolerance 失敗恢複 可靠性好
* 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 search 内置全文本搜尋
* 在Javascript 中Map/reduce 或 Erlang 支援
* Comes in “open source” and “enterprise” editions 有兩個版本
适用: 如果你希望有類似Cassandra-like (Dynamo-like)風格, 但是你不想處理器複雜性和膨脹性。單伺服器有良好可伸縮性scalability, 可用性availability 和容錯性 fault-tolerance, 采取是昂貴的多站點複制multi-site replication.
舉例: 銷售點資料收集,工廠控制系統,那些不能允許幾秒當機的場合。
HBase
(With the help of ghshephard)
* Written in: Java
* Main point: 十億級别的行 X 百萬級别的列 大容量
* License: Apache
* Protocol: HTTP/REST (also Thrift)
* Modeled after BigTable 大表模型
* Map/reduce with Hadoop 内置Map/reduce
* Query predicate push down via server side scan and get filters
* Optimizations for real time queries 能夠實時獲得基于查詢的優化
* A high performance Thrift gateway 高性能的Thrift型網關
* HTTP supports XML, Protobuf, and binary
* Cascading, hive, and pig source and sink modules
* Jruby-based (JIRB) shell
* No single point of failure 無單點風險
* Rolling restart for configuration changes and minor upgrades
* Random access performance is like MySQL 随機通路的性能類似MySQL
适用: 如果你喜歡大表模型BigTable. 你需要随機實時的讀寫操作
舉例: Facebook 消息資料庫
當然,所有這些資料庫系統都有比列在這裡多得多的功能特性。我這裡僅僅依據我個人認識列出一些關鍵特性,并且這些項目的開發也很活躍,我将盡力保持更新。