RocksDB 介绍

因为使用到了MyRocks存储引擎,需要了解下下RocksDB,发现国内介绍的不详细就自己来写一遍吧。


概述:
RocksDB 是针对KV数据存储的高性能嵌入式数据库,由Facebook的Dhruba Borthakur于2012年4月创建的LevelDB的分支,最初的
目标是提高服务工作负载的性能。
   RocksDB针对多核CPU、高效快速存储(SSD)、I/O bound workload做了优化。
基于LSM树数据结构( log-structured merge-tree),由C++编写并官方提供C、C++、Java(官方提供的
称为RocksJava)三种语言的API,社区提供了不少第三方API,如python、go等。

RocksDB是开源的软件,早前遵循BSD3协议,在2017年7月修改为遵循多协议Apache2.0和GPL v2。
目前在生产系统上主要应用于互联网企业,如Facebook、Yahoo、Linkedin等。

功能:
和LevelDB类似,存储KV到随机自己数组(),数据是按照key逐位存储或者提供了自定义的比较器。
RocksDB提供了LevelDB的所有特性,此外还有:
事务
备份和快照
列族(column families)
Bloom filters
time to live (TTL) support
universal compaction
merge operators
统计信息收集(Statistics collection)
Geospatial indexing
RocksDB在性能、新增功能、数据结构和格式、调优和管理上提供了如下功能:
Performance

Multithread compaction
Multithread memtable inserts
Reduced DB mutex holding
Optimized level-based compaction style and universal compaction style
Prefix bloom filter
Memtable bloom filter
Single bloom filter covering the whole SST file
Write lock optimization
Improved Iter::Prev() performance
Fewer comparator calls during SkipList searches
Allocate memtable memory using huge page.

Features

Column Families
Transactions and WriteBatchWithIndex
Backup and Checkpoints
Merge Operators
Compaction Filters
RocksDB Java
Manual Compactions Run in Parallel with Automatic Compactions
Persistent Cache
Bulk loading
Forward Iterators/ Tailing iterator
Single delete
Delete files in range
Pin iterator key/value

Alternative Data Structures And Formats

Plain Table format for memory-only use cases
Vector-based and hash-based memtable format
Clock-based cache (coming soon)
Pluggable information log
Annotate transaction log write with blob (for replication)

Tunability

Rate limiting
Tunable Slowdown and Stop threshold
Option to keep all files open
Option to keep all index and bloom filter blocks in block cache
Multiple WAL recovery modes
Fadvise hints for readahead and to avoid caching in OS page cache
Option to pin indexes and bloom filters of L0 files in memory
More Compression Types: zlib, lz4, zstd
Compression Dictionary
Checksum Type: xxhash
Different level size multiplier and compression type for each level.

Manageability

Statistics
Thread-local profiling
More commands in command-line tools
User-defined table properties
Event listeners
More DB Properties
Dynamic option changes
Get options from a string or map
Persistent options to option files


尽管RocksDB不是一个SQL 数据库,但是有facebook有修改了代码的MyRocks存储引擎作为MySQL的存储引擎。
和其他的NoSQL类似,RocksDB不提供关系型数据模型、不支持SQL查询,没有直接对辅助索引(secondary indexes)支持。
用户可以基于RocksDB构建自己的column families。很多应用程序把RocksDB当做库(libary),尽管他
提供server或者CLI接口。
应用:
作为嵌入式数据库,RocksDB可以作为大的DBMS的存储引擎。目前有不少数据库将其改造为存储引擎:
关系型数据库(RDBMS)
MyRocks:
facebook’s MySQL,MariaDB和Percona将其作为存储引擎
Cassandra on Rocks:Facebook的Instagram 开发了Cassandra on Rocks 提高了很多性能。
NewSQL:
CockroachDB将其作为后端的存储引擎;
TiDB 使用RocksDB作为存储引擎;
MongoDB:
Percona公司提供了MongoRocks 项目,将其作为存储引擎。
ceph存储:
ceph bluestore storage Layer 使用Rocks 作为OSD设备的元数据管理
Redis:
国内的360公司开源的pika使用rocksdb作为其后端存储。
https://github.com/Qihoo360/Pika

ArangoDB 使用RocksDB替换掉了之前的存储引擎。

由于Rocks强悍的性能,有比LevelDB更强大的功能,在区块链兴起的时代,RocksDB基本作为区块链的
基础技术之一用于存储KV数据。

资料参考:
https://github.com/facebook/rocksdb/wiki
https://en.wikipedia.org/wiki/RocksDB

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值