下圖羅列了當前MYSQL可選的數據引擎(后端),InnoDB作為默認的后端。業內有很多關于InnoDB,MyISAM和MyRocks(RockSDB)的比較,作為入門者,在此梳理一下有助于更好的了解對應的選型場景及背后的技術原因。
RocksDB vs InnoDB
RocksDB優勢:
rocksdb相對于innodb提供的API層次性更好,意味著基于rockdb開發的數據后端通用性,移植性會更好,這也是spdk目前暫時僅支持rocksdb的原因之一。性能方面之前已經有過不少的相關的對比測試,如根據http://smalldatum.blogspot.com/2016/01/rocksdb-vs-innodb-via-linkbench.html的測試結果,其指出rocksdb相較于innodb壓縮占用空間更少,同時針對磁盤的寫次數更少,盤相應時間也更少。
- Uncompressed InnoDB loads faster than MyRocks and MyRocks loads faster than compressed InnoDB. I hope to figure out how to make MyRocks load faster than uncompressed InnoDB.
- MyRocks uses about half the disk space compared to compressed InnoDB.
- MyRocks writes much less to storage than InnoDB. This allows a workload to run on low-endurance SSD with MyRocks when it requires high-endurance SSD with InnoDB.
- Average and p99 response times are much better for MyRocks
- Maximum response times were usually better for InnoDB
RocksDB劣勢:
不支持以下特性:
- 隔離僅支持RR,RC。對應可能的問題如下表:
- binlog與RocksDB之間沒有xa,異常crash可能丟數據
以下列出的限制摘錄于https://www.percona.com/doc/percona-server/LATEST/myrocks/limitations.html
ALTER TABLE ... EXCHANGE PARTITION
當前RocksDB狀態
wiki上比較清晰的梳理了當前使用rocksdb作為可選數據引擎(Alternative backend)或已內置rocksdb(Embedded)的數據庫管理系統??梢钥吹組ySQL可以用MyRocks(基于rocksdb開發)作為可選的數據引擎,Ceph的bluestore直接用了rocksdb來作為OSD節點上metadata的管理。
Alternative backend
The following projects have been started to replace or offer an alternative storage engines for already-established database systems with RocksDB:
MongoDB
The MongoRocks project provides a storage module for?MongoDB?where the storage engine is RocksDB.
A related program is Rocks Strata, a tool written in?Go, which allows managing incremental backups of MongoDB when RocksDB is used as the storage engine.
MySQL
The MyRocks project creates a new RocksDB based storage engine for?MySQL.In-depth details about MyRocks were presented at Percona Live 2016.
Cassandra
Cassandra on RocksDB can improve the performance of Apache Cassandra significantly (3-4 times faster in general, 100 times faster in some use-cases."Cassandra on RocksDB at Percona Live 2018".) The Instagram team at Facebook developed and open-sourced their code, along with benchmarks of their performance results."Open-sourcing a 10x reduction in Apache Cassandra tail latency".
Embedded
The following database systems and applications have chosen to use RocksDB as their embedded storage engine:
ArangoDB
ArangoDB?has replaced its previous storage engine ("mmfiles") with RocksDB
Ceph's BlueStore
The?Ceph's?BlueStore storage layer uses RocksDB for metadata management in OSD devices
LogDevice LogsDB
LogDevice's LogsDB is built atop RocksDB
Faktory
Facktory?the background job system uses RocksDB for storage
SSDB
The ssdb-rocks?project uses RocksDB as the storage engine for the SSDB?NoSQL Database.
TiDB
The TiDB project uses RocksDB as its storage engine
參考的鏈接:
https://dev.mysql.com/doc/refman/8.0/en/innodb-introduction.html
http://smalldatum.blogspot.com/2016/01/rocksdb-vs-innodb-via-linkbench.html
https://www.percona.com/blog/2018/02/01/myrocks-engine-things-know-start/
https://www.percona.com/doc/percona-server/LATEST/myrocks/limitations.html