Which parameter should be used for TiKV memory settings: memory-usage-limit or storage.block-cache.capacity?

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

Original topic: TiKV内存参数以memory-usage-limit、 storage.block-cache.capacity 哪个参数为准?

| username: TiDBer_yyy

[TiDB Usage Environment] Production Environment
[TiDB Version] 7.1.0
[Reproduction Path] TiKV instance total memory 64G

  1. TiDB original version 5.0.4 only set storage.block-cache.capacity=38GB
  2. After upgrading to version 7.1.0, set memory-usage-limit = 50G. After 2 months of adjustment, memory spiked to 60GB, causing TiKV OOM

[Encountered Problem: Problem Phenomenon and Impact]
Questions:

  1. When TiKV sets both memory-usage-limit and storage.block-cache.capacity, which parameter takes precedence?
  2. Why did the memory-usage-limit parameter not take effect (did not achieve the expected continuous memory release)?
| username: TiDBer_yyy | Original post link

Historical post: 关于限制TiKV实例内存使用的参数都有哪些? - #2,来自 ethercflow - TiDB 的问答社区

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

tikv memory not only has block-cache

| username: TiDBer_QYr0vohO | Original post link

This part is indeed not easy to understand.

| username: TiDBer_yyy | Original post link

Some posts say memory-usage-limit = storage.block-cache.capacity * 0.75 / 0.45

| username: terry0219 | Original post link

My personal understanding: memory-usage-limit is global and applies to the TiKV process, while block-cache sets the size of the cache.

| username: TiDBer_yyy | Original post link

I understand it the same way, but the memory-usage-limit didn’t restrict it.

| username: oceanzhang | Original post link

The TiKV node is not just block cache memory.

| username: terry0219 | Original post link

Is there a mixed deployment?

| username: TiDBer_yyy | Original post link

Independent deployment

| username: zhanggame1 | Original post link

Based on storage.block-cache.capacity, if you expect 50G, then set it to 50/1.7 for independent deployment. You can also be more conservative, for example, set it to 25G initially.

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

Do not use memory-usage-limit, just use storage.block-cache.capacity. If your TiKV host has 64GB of memory, set storage.block-cache.capacity to 64*0.45=28.8GB.

| username: oceanzhang | Original post link

Correct, no more than 60%.

| username: TiDBer_yyy | Original post link

If two parameters are configured at the same time:

memory-usage-limit < storage.block-cache.capacity * 5/3, then is the actual memory-usage-limit equal to storage.block-cache.capacity * 5/3?

| username: zhanggame1 | Original post link

You need to test it yourself, it will be fixed to a number.

| username: 呢莫不爱吃鱼 | Original post link

It’s a bit hard to understand, so I’m here to learn from everyone.

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

The parameter storage.block-cache.capacity can better limit TiKV’s memory usage. memory-usage-limit is not very effective, so I recommend using the former.

| username: TiDBer_yyy | Original post link

Got it!

| username: shigp_TIDBER | Original post link

Haven’t really deployed it yet.

| username: wangkk2024 | Original post link

Sure, please provide the Chinese text you need translated.