How to query the number of application threads in RocksDB

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: rocksdb的应用线程数怎么查询

| username: 考试没答案

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Problem Phenomenon and Impact] How to query the number of application threads in RocksDB
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachment: Screenshot/Logs/Monitoring]
image

| username: tidb菜鸟一只 | Original post link

In Grafana, go to tikv detail → Thread CPU → Async apply CPU, and check the CPU usage rate of the apply thread.


For configuration, use SHOW config WHERE NAME LIKE ‘%apply-pool-size%’
Check this, the default is 2. Generally, if the usage rate above reaches 200%, you can consider scaling up.

| username: 考试没答案 | Original post link

Is this what determines the apply of RocksDB?

| username: 考试没答案 | Original post link

Is it Rocks Raft or Rocks KVDB?

| username: TiDBer_小阿飞 | Original post link

  • The RocksDB thread pool is used for Compact and Flush tasks in RocksDB and usually does not need to be configured.
    • If the machine has a small number of CPU cores, you can set rocksdb.max-background-jobs and raftdb.max-background-jobs to 4.
    • If you encounter a Write Stall, you can check the Write Stall Reason in RocksDB-kv on Grafana monitoring to see which indicators are not zero.
      • If it is caused by pending compaction bytes, you can set rocksdb.max-sub-compactions to 2 or 3 (this configuration indicates the number of sub-threads allowed for a single compaction job, the default value is 3 in TiKV 4.0 and 1 in version 3.0).
      • If the reason is related to memtable count, it is recommended to increase the max-write-buffer-number for all columns (default is 5).
      • If the reason is related to level0 file limit, it is recommended to increase the following parameters to 64 or higher:
rocksdb.defaultcf.level0-slowdown-writes-trigger
rocksdb.writecf.level0-slowdown-writes-trigger
rocksdb.lockcf.level0-slowdown-writes-trigger
rocksdb.defaultcf.level0-stop-writes-trigger
rocksdb.writecf.level0-stop-writes-trigger
rocksdb.lockcf.level0-stop-writes-trigger
| username: TiDBer_aaO4sU46 | Original post link

SHOW config WHERE NAME LIKE ‘%apply-pool-size%’, this one mentioned by the expert is fine.

| username: 考试没答案 | Original post link

Which parameter is for the number of threads in this thread pool???

| username: h5n1 | Original post link

apply-pool-size

  • The Apply thread pool is responsible for persisting data to disk. This configuration item specifies the number of threads in the Apply thread pool, i.e., the size of the Apply thread pool. When adjusting the size of the Apply thread pool, please refer to TiKV Thread Pool Tuning.
  • Default value: 2
  • Adjustable range: [1, CPU * 10]

Apply refers to converting the content of raftlog to Kv and then writing it to rocksdb.

| username: 考试没答案 | Original post link

Thank you very much!

| username: zhang_2023 | Original post link

SHOW config WHERE NAME LIKE ‘%apply-pool-size%’

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.