title: TiKV Configuration File summary: Learn the TiKV configuration file. aliases: ['/docs/dev/tikv-configuration-file/','/docs/dev/reference/configuration/tikv-server/configuration-file/']
The TiKV configuration file supports more options than command-line parameters. You can find the default configuration file in etc/config-template.toml and rename it to config.toml
.
This document only describes the parameters that are not included in command-line parameters. For more details, see command-line parameter.
- The number of worker threads for the
HTTP
API service - Default value:
1
- Minimum value:
1
- The compression algorithm for gRPC messages
- Optional values:
none
,deflate
,gzip
- Default value:
none
- The number of gRPC worker threads
- Default value:
4
- Minimum value:
1
- The maximum number of concurrent requests allowed in a gRPC stream
- Default value:
1024
- Minimum value:
1
- The maximum number of links among TiKV nodes for Raft communication
- Default:
10
- Minimum value:
1
- The window size of the gRPC stream
- Default: 2MB
- Unit: KB|MB|GB
- Minimum value:
1KB
- The time interval at which that gRPC sends
keepalive
Ping messages - Default:
10s
- Minimum value:
1s
- Disables the timeout for gRPC streams
- Default:
3s
- Minimum value:
1s
- The maximum number of snapshots that can be sent at the same time
- Default value:
32
- Minimum value:
1
- The maximum number of snapshots that can be received at the same time
- Default value:
32
- Minimum value:
1
- The maximum number of recursive layers allowed when TiKV decodes the Coprocessor DAG expression
- Default value:
1000
- Minimum value:
1
- The longest duration allowed for a TiDB request to TiKV for processing tasks
- Default value:
60s
- Minimum value:
1s
- The maximum allowable disk bandwidth for processing snapshots
- Default value:
1000MB
- Unit: KB|MB|GB
- Minimum value:
1KB
Warning:
Unified read pool is still an experimental feature. It is NOT recommended that you use it in the production environment.
Configuration items related to the single thread pool serving read requests. This thread pool supersedes the original storage thread pool and coprocessor thread pool since the 4.0 version.
- The minimal working thread count of the unified read pool.
- Default value:
1
- The maximum working thread count of the unified read pool.
- Default value:
MAX(4, CPU * 0.8)
- The stack size of the threads in the unified thread pool.
- Default value:
10MB
- Unit: KB|MB|GB
- Minimum value:
2MB
- The maximum number of tasks allowed for a single thread in the unified read pool.
Server Is Busy
is returned when the value is exceeded. - Default value:
2000
- Minimum value:
2
Configuration items related to storage thread pool.
- Determines whether to use the unified thread pool (configured in
readpool.unified
) for storage requests. If the value of this parameter isfalse
, a separate thread pool is used, which is configured through the rest parameters in this section (readpool.storage
). - Default value:
false
- The allowable number of concurrent threads that handle high-priority
read
requests - Default value:
4
- Minimum value:
1
- The allowable number of concurrent threads that handle normal-priority
read
requests - Default value:
4
- Minimum value:
1
- The allowable number of concurrent threads that handle low-priority
read
requests - Default value:
4
- Minimum value:
1
- The maximum number of tasks allowed for a single thread in a high-priority thread pool.
Server Is Busy
is returned when the value is exceeded. - Default value:
2000
- Minimum value:
2
- The maximum number of tasks allowed for a single thread in a normal-priority thread pool.
Server Is Busy
is returned when the value is exceeded. - Default value:
2000
- Minimum value:
2
- The maximum number of tasks allowed for a single thread in a low-priority thread pool.
Server Is Busy
is returned when the value is exceeded. - Default value:
2000
- Minimum value:
2
- The stack size of threads in the Storage read thread pool
- Default value:
10MB
- Unit: KB|MB|GB
- Minimum value:
2MB
Configuration items related to the Coprocessor thread pool.
- Determines whether to use the unified thread pool (configured in
readpool.unified
) for coprocessor requests. If the value of this parameter isfalse
, a separate thread pool is used, which is configured through the rest parameters in this section (readpool.coprocessor
). - Default value: If none of the parameters in this section (
readpool.coprocessor
) are set, the default value istrue
. Otherwise, the default value isfalse
for the backward compatibility. Adjust the configuration items inreadpool.unified
before enabling this parameter.
- The allowable number of concurrent threads that handle high-priority Coprocessor requests, such as checkpoints
- Default value:
CPU * 0.8
- Minimum value:
1
- The allowable number of concurrent threads that handle normal-priority Coprocessor requests
- Default value:
CPU * 0.8
- Minimum value:
1
- The allowable number of concurrent threads that handle low-priority Coprocessor requests, such as table scan
- Default value:
CPU * 0.8
- Minimum value:
1
- The number of tasks allowed for a single thread in a high-priority thread pool. When this number is exceeded,
Server Is Busy
is returned. - Default value:
2000
- Minimum value:
2
- The number of tasks allowed for a single thread in a normal-priority thread pool. When this number is exceeded,
Server Is Busy
is returned. - Default value:
2000
- Minimum value:
2
- The number of tasks allowed for a single thread in a low-priority thread pool. When this number is exceeded,
Server Is Busy
is returned. - Default value:
2000
- Minimum value:
2
- The stack size of the thread in the Coprocessor thread pool
- Default value:
10MB
- Unit: KB|MB|GB
- Minimum value:
2MB
Configuration items related to storage
- The maximum number of messages that
scheduler
gets each time - Default value:
10240
- Minimum value:
1
- A built-in memory lock mechanism to prevent simultaneous operations on a key. Each key has a hash in a different slot.
- Default value:
2048000
- Minimum value:
1
- The number of
scheduler
threads, mainly used for checking transaction consistency before data writing - Default value:
4
- Minimum value:
1
- The maximum size of the write queue. A
Server Is Busy
error is returned for a new write to TiKV when this value is exceeded. - Default value:
100MB
- Unit: MB|GB
- The size of the temporary file that preoccupies the extra space when TiKV is started. The name of temporary file is
space_placeholder_file
, located in thestorage.data-dir
directory. When TiKV runs out of disk space and cannot be started normally, you can delete this file as an emergency intervention and setreserve-space
to0MB
. - Default value:
2GB
- Unite: MB|GB
Configuration items related to the sharing of block cache among multiple RocksDB Column Families (CF). When these configuration items are enabled, block cache separately configured for each column family is disabled.
- Enables or disables the sharing of block cache.
- Default value:
true
- The size of the shared block cache.
- Default value: 45% of the size of total system memory
- Unit: KB|MB|GB
Configuration items related to Raftstore
-
Enables or disables synchronous write mode. In the synchronous write mode, each commit is forced to be flushed to raft-log synchronously for persistent storage.
Note:
Setting the value to
false
might lead to data loss. -
Default value:
true
- Enables or disables
prevote
. Enabling this feature helps reduce jitter on the system after recovery from network partition. - Default value:
true
- The path to the Raft library, which is
storage.data-dir/raft
by default - Default value: ""
- The time interval at which the Raft state machine ticks
- Default value:
1s
- Minimum value: greater than
0
- The number of passed ticks when the heartbeat is sent. This means that a heartbeat is sent at the time interval of
raft-base-tick-interval
*raft-heartbeat-ticks
. - Default value:
2
- Minimum value: greater than
0
- The number of passed ticks when Raft election is initiated. This means that if Raft group is missing the leader, a leader election is initiated approximately after the time interval of
raft-base-tick-interval
*raft-election-timeout-ticks
. - Default value:
10
- Minimum value:
raft-heartbeat-ticks
- The minimum number of ticks during which the Raft election is initiated. If the number is
0
, the value ofraft-election-timeout-ticks
is used. The value of this parameter must be greater than or equal toraft-election-timeout-ticks
. - Default value:
0
- Minimum value:
0
- The maximum number of ticks during which the Raft election is initiated. If the number is
0
, the value ofraft-election-timeout-ticks
*2
is used. - Default value:
0
- Minimum value:
0
- The soft limit on the size of a single message packet
- Default value:
1MB
- Minimum value:
0
- Unit: MB
- The number of Raft logs to be confirmed. If this number is exceeded, log sending slows down.
- Default value:
256
- Minimum value: greater than
0
- The hard limit on the maximum size of a single log
- Default value:
8MB
- Minimum value:
0
- Unit: MB|GB
- The time interval at which the polling task of deleting Raft logs is scheduled.
0
means that this feature is disabled. - Default value:
10s
- Minimum value:
0
- The soft limit on the maximum allowable count of residual Raft logs
- Default value:
50
- Minimum value:
1
- The hard limit on the allowable number of residual Raft logs
- Default value: the log number that can be accommodated in the 3/4 Region size (calculated as 1MB for each log)
- Minimum value:
0
- The hard limit on the allowable size of residual Raft logs
- Default value: 3/4 of the Region size
- Minimum value: greater than
0
- The maximum remaining time allowed for the log cache in memory.
- Default value:
30s
- Minimum value:
0
- The protection time for new nodes, which is used to control the shortest interval to migrate a leader to the newly added node. Setting this value too small might cause the failure of leader transfer.
- Default value:
3s
- Minimum value:
0
- Enables or disables Hibernate Region. When this option is enabled, a Region idle for a long time is automatically set as hibernated. This reduces the extra overhead caused by heartbeat messages between the Raft leader and the followers for idle Regions. You can use
raftstore.peer-stale-state-check-interval
to modify the heartbeat interval between the leader and the followers of hibernated Regions. - Default value: true
- Modifies the state check interval for Regions.
- Default value: 5 min
- Specifies the interval at which to check whether the Region split is needed.
0
means that this feature is disabled. - Default value:
10s
- Minimum value:
0
- The maximum value by which the Region data is allowed to exceed before Region split
- Default value: 1/16 of the Region size.
- Minimum value:
0
- The time interval at which to check whether it is necessary to manually trigger RocksDB compaction.
0
means that this feature is disabled. - Default value:
5m
- Minimum value:
0
- Delays the time in deleting expired replica data
- Default value:
10m
- Minimum value:
0
- The number of Regions checked at one time for each round of manual compaction
- Default value:
100
- Minimum value:
0
- The number of tombstones required to trigger RocksDB compaction
- Default value:
10000
- Minimum value:
0
- The proportion of tombstone required to trigger RocksDB compaction
- Default value:
30
- Minimum value:
1
- Maximum value:
100
- The time interval at which a Region's heartbeat to PD is triggered.
0
means that this feature is disabled. - Default value:
1m
- Minimum value:
0
- The time interval at which a store's heartbeat to PD is triggered.
0
means that this feature is disabled. - Default value:
10s
- Minimum value:
0
- The time interval at which the recycle of expired snapshot files is triggered.
0
means that this feature is disabled. - Default value:
5s
- Minimum value:
0
- The longest time for which a snapshot file is saved
- Default value:
4h
- Minimum value:
0
- The time interval at which TiKV triggers a manual compaction for the Lock Column Family
- Default value:
256MB
- Default value:
10m
- Minimum value:
0
- The size out of which TiKV triggers a manual compaction for the Lock Column Family
- Default value:
256MB
- Minimum value:
0
- Unit: MB
- The longest length of the Region message queue.
- Default value:
40960
- Minimum value:
0
- The maximum number of messages processed per batch
- Default value:
4096
- Minimum value:
0
- The longest inactive duration allowed for a peer. A peer with timeout is marked as
down
, and PD tries to delete it later. - Default value:
5m
- Minimum value:
0
- The longest duration allowed for a peer to be in the state where a Raft group is missing the leader. If this value is exceeded, the peer verifies with PD whether the peer has been deleted.
- Default value:
2h
- Minimum value: greater than
abnormal-leader-missing-duration
- The longest duration allowed for a peer to be in the state where a Raft group is missing the leader. If this value is exceeded, the peer is seen as abnormal and marked in metrics and logs.
- Default value:
10m
- Minimum value: greater than
peer-stale-state-check-interval
- The time interval to trigger the check for whether a peer is in the state where a Raft group is missing the leader.
- Default value:
5m
- Minimum value: greater than
2 * election-timeout
- The maximum number of missing logs allowed for the transferee during a Raft leader transfer
- Default value:
10
- Minimum value:
10
- The memory cache size required when the imported snapshot file is written into the disk
- Default value:
10MB
- Minimum value:
0
- Unit: MB
- The time interval at which the consistency check is triggered.
0
means that this feature is disabled. - Default value:
0s
- Minimum value:
0
- The longest trusted period of a Raft leader
- Default value:
9s
- Minimum value:
0
- Determines whether to allow deleting the main switch
- Default value:
false
- The maximum number of missing logs allowed when
merge
is performed - Default value:
10
- Minimum value: greater than
raft-log-gc-count-limit
- The time interval at which TiKV checks whether a Region needs merge
- Default value:
10s
- Minimum value: greater than
0
- Determines whether to delete data from the
rocksdb delete_range
interface - Default value:
false
- The time interval at which the expired SST file is checked.
0
means that this feature is disabled. - Default value:
10m
- Minimum value:
0
- The maximum number of read requests processed in one batch
- Default value:
1024
- Minimum value: greater than
0
- The maximum number of requests for data flushing in one batch
- Default value:
1024
- Minimum value: greater than
0
- The allowable number of threads in the pool that flushes data to storage
- Default value:
2
- Minimum value: greater than
0
- The maximum number of requests processed in one batch
- Default value:
1024
- Minimum value: greater than
0
- The allowable number of threads that process Raft
- Default value:
2
- Minimum value: greater than
0
- The allowable number of threads that drive
future
- Default value:
1
- Minimum value: greater than
0
Configuration items related to Coprocessor
- Determines whether to split Region by table. It is recommended for you to use the feature only in TiDB mode.
- Default value:
true
- The threshold of Region split in batches. Increasing this value speeds up Region split.
- Default value:
10
- Minimum value:
1
- The maximum size of a Region. When the value is exceeded, the Region splits into many.
- Default value:
144MB
- Unit: KB|MB|GB
- The size of the newly split Region. This value is an estimate.
- Default value:
96MB
- Unit: KB|MB|GB
- The maximum allowable number of keys in a Region. When this value is exceeded, the Region splits into many.
- Default value:
1440000
- The number of keys in the newly split Region. This value is an estimate.
- Default value:
960000
Configuration items related to RocksDB
- The number of background threads in RocksDB
- Default value:
8
- Minimum value:
1
- The number of sub-compaction operations performed concurrently in RocksDB
- Default value:
1
- Minimum value:
1
- The total number of files that RocksDB can open
- Default value:
40960
- Minimum value:
-1
- The maximum size of a RocksDB Manifest file
- Default value:
128MB
- Minimum value:
0
- Unit: B|KB|MB|GB
- Determines whether to automatically create a DB switch
- Default value:
true
- WAL recovery mode
- Optional values:
0
(TolerateCorruptedTailRecords
),1
(AbsoluteConsistency
),2
(PointInTimeRecovery
),3
(SkipAnyCorruptedRecords
) - Default value:
2
- Minimum value:
0
- Maximum value:
3
- The directory in which WAL files are stored
- Default value:
/tmp/tikv/store
- The living time of the archived WAL files. When the value is exceeded, the system deletes these files.
- Default value:
0
- Minimum value:
0
- unit: second
- The size limit of the archived WAL files. When the value is exceeded, the system deletes these files.
- Default value:
0
- Minimum value:
0
- Unit: B|KB|MB|GB
- Determines whether to automatically optimize the configuration of Rate LImiter
- Default value:
false
- Enables or disables Pipelined Write
- Default value:
true
- The size of
readahead
when compaction is being performed - Default value:
0
- Minimum value:
0
- Unit: B|KB|MB|GB
- The maximum buffer size used in WritableFileWrite
- Default value:
1MB
- Minimum value:
0
- Unit: B|KB|MB|GB
- Determines whether to use
O_DIRECT
for both reads and writes in background flush and compactions - Default value:
false
- The maximum rate permitted by Rate Limiter
- Default value:
0
- Minimum value:
0
- Unit: Bytes
- Rate LImiter mode
- Optional values:
1
(ReadOnly
),2
(WriteOnly
),3
(AllIo
) - Default value:
2
- Minimum value:
1
- Maximum value:
3
- Determines whether to automatically optimize the configuration of the Rate LImiter
- Default value:
false
- Enables or disables Pipelined Write
- Default value:
true
- The rate at which OS incrementally synchronizes files to disk while these files are being written asynchronously
- Default value:
1MB
- Minimum value:
0
- Unit: B|KB|MB|GB
- The rate at which OS incrementally synchronizes WAL files to disk while the WAL files are being written
- Default value:
512KB
- Minimum value:
0
- Unit: B|KB|MB|GB
- The maximum size of Info log
- Default value:
1GB
- Minimum value:
0
- Unit: B|KB|MB|GB
- The time interval at which Info logs are truncated. If the value is
0
, logs are not truncated. - Default value:
0
- The maximum number of kept log files
- Default value:
10
- Minimum value:
0
- The directory in which logs are stored
- Default value: ""
Configuration items related to Titan
- Enables or disables Titan
- Default value:
false
- The directory in which the Titan Blob file is stored
- Default value:
titandb
- Determines whether to disable Garbage Collection (GC) that Titan performs to Blob files
- Default value:
false
- The maximum number of GC threads in Titan
- Default value:
1
- Minimum value:
1
Configuration items related to rocksdb.defaultcf
- The default size of a RocksDB block
- Default value:
64KB
- Minimum value:
1KB
- Unit: KB|MB|GB
- The cache size of a RocksDB block
- Default value:
Total machine memory / 4
- Minimum value:
0
- Unit: KB|MB|GB
- Enables or disables block cache
- Default value:
false
- Enables or disables caching index and filter
- Default value:
true
- Determines whether to pin the index and filter at L0
- Default value:
true
- Enables or disables bloom filter
- Default value:
true
- Determines whether to optimize the hit ratio of filters
- Default value:
true
- Determines whether to put the entire key to bloom filter
- Default value:
true
- The length that bloom filter reserves for each key
- Default value:
10
- unit: byte
- Determines whether each block creates a bloom filter
- Default value:
false
- Enables or disables statistics of read amplification.
- Optional values:
0
(disabled), >0
(enabled). - Default value:
0
- Minimum value:
0
- The default compression algorithm for each level
- Optional values: ["no", "no", "lz4", "lz4", "lz4", "zstd", "zstd"]
- Default value:
No
for the first two levels, andlz4
for the next five levels
- Memtable size
- Default value:
128MB
- Minimum value:
0
- Unit: KB|MB|GB
- The maximum number of memtables
- Default value:
5
- Minimum value:
0
- The minimum number of memtables required to trigger flush
- Default value:
1
- Minimum value:
0
- The maximum number of bytes at base level (L1). Generally, it is set to 4 times the size of a memtable.
- Default value:
512MB
- Minimum value:
0
- Unit: KB|MB|GB
- The size of the target file at base level
- Default:
8MB
- Minimum value:
0
- Unit: KB|MB|GB
- The maximum number of files at L0 that trigger compaction
- Default value:
4
- Minimum value:
0
- The maximum number of files at L0 that trigger write stall
- Default value:
20
- Minimum value:
0
- The maximum number of files at L0 required to completely block write
- Default value:
36
- Minimum value:
0
- The maximum number of bytes written into disk per compaction
- Default value:
2GB
- Minimum value:
0
- Unit: KB|MB|GB
- The priority type of compaction
- Optional values:
3
(MinOverlappingRatio
),0
(ByCompensatedSize
),1
(OldestLargestSeqFirst
),2
(OldestSmallestSeqFirst
) - Default value:
3
- Determines whether to optimize dynamic level bytes
- Default value:
true
- The maximum number of levels in a RocksDB file
- Default value:
7
- The default amplification multiple for each layer
- Default value:
10
- Compaction method
- Optional values:
level
,universal
- Default value:
level
- Enables or disables automatic compaction
- Default value:
false
- The soft limit on the pending compaction bytes
- Default value:
64GB
- Unit: KB|MB|GB
- The hard limit on the pending compaction bytes
- Default value:
256GB
- Unit: KB|MB|GB
Configuration items related to rocksdb.defaultcf.titan
- The smallest value stored in a Blob file. Values smaller than the specified size are stored in the LSM-Tree.
- Default value:
1KB
- Minimum value:
0
- Unit: KB|MB|GB
- The compression algorithm used in a Blob file
- Optional values:
no
,snappy
,zlib
,bzip2
,lz4
,lz4hc
,zstd
- Default value:
lz4
- The cache size of a Blob file
- Default value:
0GB
- Minimum value:
0
- Unit: KB|MB|GB
- The minimum total size of Blob files required to perform GC for one time
- Default value:
16MB
- Minimum value:
0
- Unit: KB|MB|GB
- The maximum total size of Blob files allowed to perform GC for one time
- Default value:
64MB
- Minimum value:
0
- Unit: KB|MB|GB
- The ratio at which GC is triggered for Blob files. The Blob file can be selected for GC only if the proportion of the invalid values in a Blob file exceeds this ratio.
- Default value:
0.5
- Minimum value:
0
- Maximum value:
1
- The ratio of (data read from a Blob file/the entire Blob file) when sampling the file during GC
- Default value:
0.1
- Minimum value:
0
- Maximum value:
1
- When the size of a Blob file is smaller than this value, the Blob file might still be selected for GC. In this situation,
discardable-ratio
is ignored. - Default value:
8MB
- Minimum value:
0
- Unit: KB|MB|GB
- Specifies the running mode of Titan.
- Optional values:
normal
: Writes data to the blob file when the value size exceedsmin-blob-size
.read_only
: Refuses to write new data to the blob file, but still reads the original data from the blob file.fallback
: Writes data in the blob file back to LSM.
- Default value:
normal
- Determines whether to optimize the read performance. When
level-merge
is enabled, there is more write amplification. - Default value:
false
- Determines whether to use the merge operator to write back blob indexes for Titan GC. When
gc-merge-rewrite
is enabled, it reduces the effect of Titan GC on the writes in the foreground. - Default value:
false
Configuration items related to rocksdb.writecf
- Block cache size
- Default value:
Total machine memory * 15%
- Unit: MB|GB
- Determines whether to optimize the hit ratio of the filter
- Default value:
false
- Determines whether to put the entire key to bloom filter
- Default value:
false
Configuration items related to rocksdb.lockcf
- Block cache size
- Default value:
Total machine memory * 2%
- Unit: MB|GB
- Determines whether to optimize the hit ratio of the filter
- Default value:
false
- The number of files at L0 required to trigger compaction
- Default value:
1
Configuration items related to raftdb
- The number of background threads in RocksDB
- Default value:
2
- Minimum value:
1
- The number of concurrent sub-compaction operations performed in RocksDB
- Default value:
1
- Minimum value:
1
- The directory in which WAL files are stored
- Default value:
/tmp/tikv/store
Configuration items related to security
- The path of the CA file
- Default value: ""
- The path of the Privacy Enhanced Mail (PEM) file that contains the X509 certificate
- Default value: ""
- The path of the PEM file that contains the X509 key
- Default value: ""
Configuration items related to import
- The number of threads to process RPC requests
- Default value:
8
- Minimum value:
1
- The number of jobs imported concurrently
- Default value:
8
- Minimum value:
1
- Enables the pessimistic transaction mode. For pessimistic transaction usage, refer to TiDB Pessimistic Transaction Mode.
- Default value:
true
- The longest time that a pessimistic transaction in TiKV waits for other transactions to release the lock. If the time is out, an error is returned to TiDB, and TiDB retries to add a lock. The lock wait timeout is set by
innodb_lock_wait_timeout
. - Default value: 1 s
- Minimum value: 1 ms
- When pessimistic transactions release the lock, among all the transactions waiting for lock, only the transaction with the smallest
start_ts
is woken up. Other transactions will be woken up afterwait-up-delay-duration
. - Default value: 20 ms
This configuration item enables the pipelined process of adding the pessimistic lock. With this feature enabled, after detecting that data can be locked, TiKV immediately notifies TiDB to execute the subsequent requests and write the pessimistic lock asynchronously, which reduces most of the latency and significantly improves the performance of pessimistic transactions. But there is a still low probability that the asynchronous write of the pessimistic lock fails, which might cause the failure of pessimistic transaction commits.
The default value of pipelined
is false
.