What is TiKV memory usage related to?

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

Original topic: TIKV内存使用和什么有关?

| username: jaybing926

[TiDB Usage Environment] Production Environment
[TiDB Version]
[Encountered Problem: Phenomenon and Impact]
I would like to ask what factors affect the memory usage of TiKV nodes?
Is it related to the number of regions? But I see that in my current TiKV nodes, all of them are using 1.5T of data, yet some use over 60G of memory while others use less than 35G. This indicates that it is not related to the number of regions or the data volume. So, what is it related to?

| username: WalterWj | Original post link

Why is there no leader on 58?

TiKV memory is generally resident memory. If not configured, it uses about 80% of the physical machine.

Are the server configurations uniform?

| username: jaybing926 | Original post link

Node 58 might be unstable, but it’s unclear where the instability lies. Previously, the leader on node 58 frequently went offline, and over time, possibly due to TiDB’s mechanism, it stopped assigning the leader to it altogether. So now it’s like this~

| username: WalterWj | Original post link

Try using pd-ctl to check if there is a leader eviction schedule.

| username: jaybing926 | Original post link

How should I look at this specifically? Could you please guide me, teacher?

| username: WalterWj | Original post link

PD Control 使用说明 | PingCAP 文档中心 This

| username: jaybing926 | Original post link

Is there a problem with my command? Or is it a version issue? Why can’t I see it? I’m using v4.0.9.

| username: TiDBer_jYQINSnf | Original post link

There is an evict-leader-scheduler above, and it is estimated that 58 was evicted by this.
Memory is closely related to RocksDB.
The underlying TiKV consists of two RocksDB instances.
In RocksDB, there are blockcache and memtable.
For memory tuning, refer to:

| username: jaybing926 | Original post link

How can I view detailed information about evict-leader-scheduler? I’m not familiar with the command.

| username: jaybing926 | Original post link

I looked at the documentation, and it says that TiKV’s memory usage is mainly related to the block-cache, which is associated with hot data and not directly related to the size of the data. The write-buffer, from what I see, has a very small actual memory configuration. There’s also the page cache used for queries.

| username: TiDBer_jYQINSnf | Original post link

scheduler config evict-leader-scheduler

| username: TiDBer_jYQINSnf | Original post link

Block-cache is a cache that can be adjusted in size. The larger it is, the more hot data it can cache, which is beneficial for reducing query latency.

| username: jaybing926 | Original post link

This command doesn’t work, strange~

| username: 裤衩儿飞上天 | Original post link

The image link you provided appears to be broken or inaccessible. Please provide the text you need translated.

| username: jaybing926 | Original post link

Are you saying like this? It still doesn’t work.

| username: TiDBer_jYQINSnf | Original post link

I found it from here, I remember seeing it before as well.

Mine is version 5.4.0, and I can see it too.

| username: TiDBer_jYQINSnf | Original post link

If your version is before 4.0, you won’t be able to view it.

| username: jaybing926 | Original post link

I am v4.0.9

| username: jaybing926 | Original post link

Strange, I saw the explanation of this command in the official documentation for version 4.0, and it has this usage. Why can’t I use it?

| username: 裤衩儿飞上天 | Original post link

I don’t have the 4.X version here either.
You can use scheduler -h to check the help; all the commands and prompts are available.