Titan is a RocksDB plugin developed by PingCAP to separate keys and values in RocksDB storage. The goal of Titan is to reduce the write amplification when storing large values.

How Titan works

RocksDB Titan Config - 图1

Titan Architecture

Titan store values separately from the LSM-tree during flush and compaction. The value in the LSM tree is the position index to the blob file of the real value. For more details on the design and implementation of Titan, see Titan: A RocksDB Plugin to Reduce Write Amplification.

Notes: Although Titan improves write performance, it enlarges data storage size and reduces range scan performance at the same time. Therefore, it is recommended to use Titan when the average size of values is larger than 1KB.

How to enable Titan

As Titan has not reached ultimate maturity to be applied in production, it is disabled in TiKV by default. Before enabling it, make sure you understand the above notes and have evaluated your scenario and needs.

To enable Titan in TiKV, set the following in the TiKV configuration file:

  1. [rocksdb.titan]
  2. # Enables or disables `Titan`. Note that Titan is still an experimental feature.
  3. # default: false
  4. enabled = true

For the information of all the Titan configuration parameters, see Titan-related parameters.

How to fall back to RocksDB

If you find Titan does not help or causes read or other performance issues, you can take the following steps to fall back to RocksDB:

  1. Enter the fallback mode using tikv-ctl:

    1. tikv-ctl --host 127.0.0.1:20160 modify-tikv-config -m kvdb -n default.blob_run_mode -v "kFallback"

    When using this command, make sure you have already enabled Titan.

  2. Wait until the number of blob files reduces to 0. You can also accelerate it by tikv-ctl compact-cluster.

  3. Set rocksdb.titan.enabled=false in the TiKV configuration file, and then restart TiKV.