Issues with Adjusting Memory for Default TiDB Deployment Using docker-compose.yml

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

Original topic: 使用docker-compose.yml默认部署TiDB相关内存调整的问题

| username: wenrou

[TiDB Usage Environment] Production Environment
[TiDB Version] v7.1.0
[Encountered Problem: Phenomenon and Impact] Memory adjustment for TiDB related components in the default docker-compose.yml deployment
[Attachment: Screenshot/Log/Monitoring]




High memory usage in the database can easily cause the server to freeze. Is it possible to modify the configuration file to keep the memory usage within a certain ratio?
If so, which configuration file and which parameter should be modified?

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

Find your docker-compose.yml configuration file and see where the tikv configuration file is located. Modify the block-cache-size in the configuration file, setting this value smaller. It should not exceed your physical machine’s memory divided by the number of tikv nodes divided by 2.

| username: wenrou | Original post link

There are multiple block-cache-size settings in the tikv.toml configuration file. Which specific one should be modified?

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

You are on 7.1, this parameter was deprecated after 6.6. Just check your current show config like '%storage.block-cache.capacity%'; to see what value is set first.

| username: wenrou | Original post link

Where should this command be executed? It doesn’t respond when executed in the database.

| username: Kongdom | Original post link

Have you checked the official memory tuning documentation?

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

show config like ‘%block-cache%’; take a look

| username: wenrou | Original post link

I have read the official documentation, but I don’t quite understand it.
image
Three TiKV instances are deployed on one server, and there are multiple block-cache-size properties in the tikv.toml configuration file. I don’t know how to modify them.
tikv.toml (17.5 KB)

| username: wenrou | Original post link

Or

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

Or set the capacity in the configuration file to the size of the physical machine’s memory divided by the number of TiKV nodes divided by 2.

| username: Kongdom | Original post link

Are you deploying on a single node?

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

How about show config like '%capacity%';?

| username: wenrou | Original post link

Deployed using docker-compose on a virtual machine.

| username: Kongdom | Original post link

Oh, for hybrid deployment, you can refer to this.

| username: wenrou | Original post link

Executing it in the database yields no results.

| username: Kongdom | Original post link

It’s the same, but it’s best to set it by dividing the standard value by 3. :joy: However, this might make the value relatively small. You can verify it; if the standard value works, set it according to the standard value. If not, adjust it accordingly.

| username: Kongdom | Original post link

Does this have value?

SHOW config WHERE name LIKE '%capacity%'

| username: wenrou | Original post link

Currently, in the tikv.toml configuration file, there are multiple locations with the block-cache-size attribute that are commented out. If I uncomment them, there are options for 1GB and 256MB. I’m afraid of crashing the database and don’t dare to make changes lightly. This is a production database that is currently in use, so I want to ask an expert for specific advice.

| username: wenrou | Original post link

There is a value

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

Assuming you choose a virtual machine with a total of 100G and deploy so many things on it:
set config tikv storage.block-cache.capacity=5G;
I suggest you set it smaller first, otherwise, it feels very easy to OOM.