百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

terarkdb

> 编程语言
开源

一个与 RocksDB 兼容的 KV 存储引擎,性能更好

2.2K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个与 RocksDB 兼容的 KV 存储引擎,性能更好

Introduction

TerarkDB is a RocksDB replacement with optimized tail latency, throughput and compression etc. In most cases you can migrate your existing RocksDB instance to TerarkDB without any drawbacks.

  • All-in-one Docs
  • Slack Channel

NOTES

  • TerarkDB was only tested and production ready under Linux platform
  • Language bindings except C/C++ are not fully tested yet.
  • Existing data can be migrated from RocksDB directly to TerarkDB, but cannot migrate back to RocksDB.
  • TerarkDB was forked from RocksDB v5.18.3.

Performance Overview

  • RocksDB v6.12
  • Server
    • Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz (2 Sockets, 32 cores 64 threads)
    • 376 GB DRAM
    • NVMe TLC SSD (3.5 TB)
  • Bench Tools & Workloads
    • use db_bench
    • 10 client threads, 20GB requests per thread
    • key = 24 bytes, value = 2000 bytes
    • heavy_write means 90% write operations
    • heavy_read means 90% read operations

1. Use TerarkDB

Prerequisite

If you enabled TerarkZipTable support (-DWITH_TERARK_ZIP=ON), you should install libaio before compile TerarkDB:

sudo apt-get install libaio-dev

If this is your first time using TerarkDB, we recommend you to use without TerarkZipTable by changing -DWITH_TERARK_ZIP to OFF in build.sh.

Method 1: Use CMake subdirectory (Recommend)

  1. Clone
cd {YOUR_PROJECT_DIR}
git submodule add https://github.com/bytedance/terarkdb.git

cd terarkdb && git submodule update --init --recursive
  1. Edit your Top Project's CMakeLists.txt
add_subdirectory(terarkdb)
target_link_libraries({YOUR_TARGET} terarkdb)
  1. Important Default Options
  • CMAKE_BUILD_TYPE: RelWithDebInfo
  • WITH_JEMALLOC: ON
    • Use Jemalloc or Not (If you are using a different malloc library, change to OFF)
  • WITH_TESTS: OFF
    • Build test cases
  • WITH_TOOLS: OFF
    • Build with TerarkDB tools (e.g. db_bench, ldb etc)
  • WITH_TERARK_ZIP: OFF
    • Build with TerarkZipTable
  • WITH_ZNS: OFF
    • Build with ZNS device support

Notes

  • TerarkDB is built with zstd, lz4, snappy, zlib, gtest, boost by default, if you need these libraries, you can remove them from your higher level application.

Method 2: Link as static library

  1. clone & build
git clone https://github.com/bytedance/terarkdb.git

cd terarkdb && git submodule update --init --recursive

WITH_TESTS=OFF WITH_ZNS=OFF ./build.sh
  1. linking

Directory:

  terarkdb/
        \___ output/
                \_____ include/
                \_____ lib/
                         \___ libterarkdb.a
                         \___ libzstd.a
                         \___ ...

We didn't archieve all static libraries together yet, so you have to pack all libraries to your target:

-Wl,-Bstatic \
-lterarkdb -lbz2 -ljemalloc -llz4 -lsnappy -lz -lzstd \
-Wl,-Bdynamic -pthread -lgomp -lrt -ldl -laio

2. Usage

2.1. BlockBasedTable

#include <cassert>
#include "rocksdb/db.h"

rocksdb::DB* db;
rocksdb::Options options;

// Your options here
options.create_if_missing = true;
options.wal_bytes_per_sync = 32768;
options.bytes_per_sync = 32768;

// Open DB
auto status = rocksdb::DB::Open(options, "/tmp/testdb", &db);

// Operations
std::string value;
auto s = db->Put(rocksdb::WriteOptions(), "key1", "value1");
s = db->Get(rocksdb::ReadOptions(), "key1", &value);
assert(s.ok());
assert("value1" == value);

s = db->Delete(rocksdb::WriteOptions(), "key1");
assert(s.ok());

Or manually set table format and table options:

…

2.2. TerarkZipTable

…

3. Real-world Performance Improvement

TerarkDB has been deployed in lots of applications in Bytedance, in most cases TerarkDB can help to reduce latency spike and improve throughput tremendously.

Disk Write

Get Latency (us)

4. Contributing

  • TerarkDB uses Github issues and pull requests to manage features and bug fixes.
  • All PRs are welcome including code formating and refactoring.

5. License

  • Apache 2.0

6. Users

Please let us know if you are using TerarkDB, thanks! (By joining our slack channel)

  • ByteDance (core online services)

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言