From 41506d0f3f1313c52a208a235f9c64868d97307d Mon Sep 17 00:00:00 2001 From: TomShawn <1135243111@qq.com> Date: Tue, 7 Apr 2020 20:36:42 +0800 Subject: [PATCH 1/7] tiflash: add tiflash tuning document --- TOC.md | 1 + reference/tiflash/tune-performance.md | 96 +++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 reference/tiflash/tune-performance.md diff --git a/TOC.md b/TOC.md index 4d3b48547e1d1..c5b1f945bf498 100644 --- a/TOC.md +++ b/TOC.md @@ -307,6 +307,7 @@ - [Overview](/reference/tiflash/overview.md) - [Deploy a TiFlash Cluster](/reference/tiflash/deploy.md) - [Use TiFlash](/reference/tiflash/use-tiflash.md) + - [Tune TiKV Performance](/reference/tiflash/tune-performance.md) + TiDB Binlog - [Overview](/reference/tidb-binlog/overview.md) - [Deploy](/reference/tidb-binlog/deploy.md) diff --git a/reference/tiflash/tune-performance.md b/reference/tiflash/tune-performance.md new file mode 100644 index 0000000000000..151be46a91818 --- /dev/null +++ b/reference/tiflash/tune-performance.md @@ -0,0 +1,96 @@ +--- +title: Tune TiFlash Performance +category: reference +--- + +# Tune TiFlash Performance + +This document introduces how to tune the performance of TiFlash, including planning machine resources, TiDB parameter tuning, and set the size of TiKV Regions. + +## Plan resources + +If you want to save machine resources and have no requirement on isolation, you can use the method that combines the deployment of both TiKV and TiFlash. It is recommended that you save enough resources for TiKV and TiFlash, and do not share disks. + +## TiDB parameter tuning + +1. For the TiDB node dedicated to OLAP/TiFlash, it is recommended that you increase the value of the [`tidb_distsql_scan_concurrency`](/reference/configuration/tidb-server/tidb-specific-variables.md#tidb_distsql_scan_concurrency) configuration item for this node to `80`: + + {{< copyable "sql" >}} + + ```sql + set @@tidb_distsql_scan_concurrency = 80; + ``` + +2. Enable the optimization for TiDB Operator by enabling the aggregate pushdown of `JOIN` or `UNION`: + + {{< copyable "sql" >}} + + ```sql + set @@tidb_opt_agg_push_down = 1; + ``` + +## Configure the size of TiKV Regions + +The number and size of Regions might have some impact on TiFlash performance. Too many small Regions might bring down TiFlash performance by several times. + +For user scenarios that focus on analysis and query, it is recommended that you set the Region size to 192MB, and enable the Region Merge feature to ensure that small Regions generated during operation are automatically merged. + +This section introduces how to set Region size and enable Region Merge for TiDB clusters that are deployed in different ways. + +### For clusters deployed using TiDB Ansible + +For clusters deployed using TiDB Ansible, use the following methods to set Region size and enable Region Merge: + ++ Add the following configuration in the `roles/tikv/vars/default.yml` file and then restart the cluster to modify the Region size. + + {{< copyable "" >}} + + ```yaml + coprocessor: + region-max-size: "288MiB" + region-split-size: "192MiB" + region-max-keys: 2880000 + region-split-keys: 1920000 + ``` + ++ Add the following configuration in the `roles/pd/vars/default.yml` file to enable Region Merge. You can also execute the `config set ` command in pd-ctl to enable this feature. + + {{< copyable "" >}} + + ```yaml + schedule: + max-merge-region-size: 20 # Merges Regions smaller that 20MB. + max-merge-region-keys: 200000 # Merges Regions with less than 20,000 keys. + split-merge-interval: "1h" + merge-schedule-limit: 8 # Controls the speed of merge. Setting this value to 0 will disable Region Merge. + ``` + +### For clusters deployed not using TiDB Ansible + +For TiDB clusters deployed not using TiDB Ansible, use the following methods to set Region size and enable Region Merge: + ++ Add the following configuration in the `tikv.toml` file and then restart the cluster to modify the Region size. + + {{< copyable "" >}} + + ```toml + [coprocessor] + region-max-size = "288MiB" + region-split-size = "192MiB" + region-max-keys = 2880000 + region-split-keys = 1920000 + ``` + ++ Add the following configuration in the `pd.toml` file to enable Region Merge: + + {{< copyable "" >}} + + ```toml + [schedule] + max-merge-region-size = 20 + max-merge-region-keys = 200000 + split-merge-interval = "1h" + merge-schedule-limit = 8 + ``` + + You can also execute the `config set ` command in pd-ctl to enable Region Merge. From 563527964e1f669ded951df6244e758dcf652122 Mon Sep 17 00:00:00 2001 From: TomShawn <1135243111@qq.com> Date: Tue, 7 Apr 2020 20:44:28 +0800 Subject: [PATCH 2/7] add summary --- reference/tiflash/tune-performance.md | 1 + 1 file changed, 1 insertion(+) diff --git a/reference/tiflash/tune-performance.md b/reference/tiflash/tune-performance.md index 151be46a91818..fb1b84989ea0f 100644 --- a/reference/tiflash/tune-performance.md +++ b/reference/tiflash/tune-performance.md @@ -1,5 +1,6 @@ --- title: Tune TiFlash Performance +summary: Learn how to tune the performance of TiFlash. category: reference --- From d845136cd7da16f2aee68333aefb38839f5d00fb Mon Sep 17 00:00:00 2001 From: TomShawn <1135243111@qq.com> Date: Tue, 7 Apr 2020 21:13:24 +0800 Subject: [PATCH 3/7] update content --- reference/tiflash/tune-performance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/tiflash/tune-performance.md b/reference/tiflash/tune-performance.md index fb1b84989ea0f..c4729d8c62191 100644 --- a/reference/tiflash/tune-performance.md +++ b/reference/tiflash/tune-performance.md @@ -22,7 +22,7 @@ If you want to save machine resources and have no requirement on isolation, you set @@tidb_distsql_scan_concurrency = 80; ``` -2. Enable the optimization for TiDB Operator by enabling the aggregate pushdown of `JOIN` or `UNION`: +2. Enable the optimization for TiDB Operator such as the aggregate pushdown of `JOIN` or `UNION`: {{< copyable "sql" >}} From 16a10486a4e826650c75d053ab3c9d74a0fa914d Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Wed, 8 Apr 2020 11:29:26 +0800 Subject: [PATCH 4/7] Apply suggestions from code review Co-Authored-By: Ran --- TOC.md | 2 +- reference/tiflash/tune-performance.md | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/TOC.md b/TOC.md index c5b1f945bf498..06f82241f2c3f 100644 --- a/TOC.md +++ b/TOC.md @@ -307,7 +307,7 @@ - [Overview](/reference/tiflash/overview.md) - [Deploy a TiFlash Cluster](/reference/tiflash/deploy.md) - [Use TiFlash](/reference/tiflash/use-tiflash.md) - - [Tune TiKV Performance](/reference/tiflash/tune-performance.md) + - [Tune TiFlash Performance](/reference/tiflash/tune-performance.md) + TiDB Binlog - [Overview](/reference/tidb-binlog/overview.md) - [Deploy](/reference/tidb-binlog/deploy.md) diff --git a/reference/tiflash/tune-performance.md b/reference/tiflash/tune-performance.md index c4729d8c62191..f5c247694d0f9 100644 --- a/reference/tiflash/tune-performance.md +++ b/reference/tiflash/tune-performance.md @@ -6,13 +6,13 @@ category: reference # Tune TiFlash Performance -This document introduces how to tune the performance of TiFlash, including planning machine resources, TiDB parameter tuning, and set the size of TiKV Regions. +This document introduces how to tune the performance of TiFlash, including planning machine resources, tuning TiDB parameters, and setting the size of TiKV Regions. ## Plan resources -If you want to save machine resources and have no requirement on isolation, you can use the method that combines the deployment of both TiKV and TiFlash. It is recommended that you save enough resources for TiKV and TiFlash, and do not share disks. +If you want to save machine resources and have no requirement on isolation, you can use the method that combines the deployment of both TiKV and TiFlash. It is recommended that you save enough resources for TiKV and TiFlash respectively, and do not share disks. -## TiDB parameter tuning +## Tune TiDB parameters 1. For the TiDB node dedicated to OLAP/TiFlash, it is recommended that you increase the value of the [`tidb_distsql_scan_concurrency`](/reference/configuration/tidb-server/tidb-specific-variables.md#tidb_distsql_scan_concurrency) configuration item for this node to `80`: @@ -42,7 +42,7 @@ This section introduces how to set Region size and enable Region Merge for TiDB For clusters deployed using TiDB Ansible, use the following methods to set Region size and enable Region Merge: -+ Add the following configuration in the `roles/tikv/vars/default.yml` file and then restart the cluster to modify the Region size. ++ To modify the Region size, add the following configuration in the `roles/tikv/vars/default.yml` file and then restart the cluster. {{< copyable "" >}} @@ -54,13 +54,13 @@ For clusters deployed using TiDB Ansible, use the following methods to set Regio region-split-keys: 1920000 ``` -+ Add the following configuration in the `roles/pd/vars/default.yml` file to enable Region Merge. You can also execute the `config set ` command in pd-ctl to enable this feature. ++ To enable Region Merge, add the following configuration in the `roles/pd/vars/default.yml` file. You can also execute the `config set ` command in pd-ctl to enable this feature. {{< copyable "" >}} ```yaml schedule: - max-merge-region-size: 20 # Merges Regions smaller that 20MB. + max-merge-region-size: 20 # Merges Regions smaller that 20 MB. max-merge-region-keys: 200000 # Merges Regions with less than 20,000 keys. split-merge-interval: "1h" merge-schedule-limit: 8 # Controls the speed of merge. Setting this value to 0 will disable Region Merge. @@ -70,7 +70,7 @@ For clusters deployed using TiDB Ansible, use the following methods to set Regio For TiDB clusters deployed not using TiDB Ansible, use the following methods to set Region size and enable Region Merge: -+ Add the following configuration in the `tikv.toml` file and then restart the cluster to modify the Region size. ++ To modify the Region size, add the following configuration in the `tikv.toml` file and then restart the cluster. {{< copyable "" >}} @@ -82,7 +82,7 @@ For TiDB clusters deployed not using TiDB Ansible, use the following methods to region-split-keys = 1920000 ``` -+ Add the following configuration in the `pd.toml` file to enable Region Merge: ++ To enable Region Merge, add the following configuration in the `pd.toml` file: {{< copyable "" >}} From ed3fcffa8d769744dfb7bd14f5c747e73bde50b0 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Wed, 8 Apr 2020 11:45:10 +0800 Subject: [PATCH 5/7] Update reference/tiflash/tune-performance.md Co-Authored-By: Ran --- reference/tiflash/tune-performance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/tiflash/tune-performance.md b/reference/tiflash/tune-performance.md index f5c247694d0f9..8f9a1e80551b6 100644 --- a/reference/tiflash/tune-performance.md +++ b/reference/tiflash/tune-performance.md @@ -34,7 +34,7 @@ If you want to save machine resources and have no requirement on isolation, you The number and size of Regions might have some impact on TiFlash performance. Too many small Regions might bring down TiFlash performance by several times. -For user scenarios that focus on analysis and query, it is recommended that you set the Region size to 192MB, and enable the Region Merge feature to ensure that small Regions generated during operation are automatically merged. +For user scenarios that focus on analysis and query, it is recommended that you set the Region size to 192 MB, and enable the Region Merge feature to ensure that small Regions generated during operation are automatically merged. This section introduces how to set Region size and enable Region Merge for TiDB clusters that are deployed in different ways. From 9762dbf06575f7a9ef811c7379acd13fb0a75a2c Mon Sep 17 00:00:00 2001 From: TomShawn <1135243111@qq.com> Date: Thu, 9 Apr 2020 20:33:33 +0800 Subject: [PATCH 6/7] align #2686 --- reference/tiflash/tune-performance.md | 68 +-------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) diff --git a/reference/tiflash/tune-performance.md b/reference/tiflash/tune-performance.md index 8f9a1e80551b6..2618150c91975 100644 --- a/reference/tiflash/tune-performance.md +++ b/reference/tiflash/tune-performance.md @@ -6,7 +6,7 @@ category: reference # Tune TiFlash Performance -This document introduces how to tune the performance of TiFlash, including planning machine resources, tuning TiDB parameters, and setting the size of TiKV Regions. +This document introduces how to tune the performance of TiFlash, including planning machine resources and tuning TiDB parameters ## Plan resources @@ -29,69 +29,3 @@ If you want to save machine resources and have no requirement on isolation, you ```sql set @@tidb_opt_agg_push_down = 1; ``` - -## Configure the size of TiKV Regions - -The number and size of Regions might have some impact on TiFlash performance. Too many small Regions might bring down TiFlash performance by several times. - -For user scenarios that focus on analysis and query, it is recommended that you set the Region size to 192 MB, and enable the Region Merge feature to ensure that small Regions generated during operation are automatically merged. - -This section introduces how to set Region size and enable Region Merge for TiDB clusters that are deployed in different ways. - -### For clusters deployed using TiDB Ansible - -For clusters deployed using TiDB Ansible, use the following methods to set Region size and enable Region Merge: - -+ To modify the Region size, add the following configuration in the `roles/tikv/vars/default.yml` file and then restart the cluster. - - {{< copyable "" >}} - - ```yaml - coprocessor: - region-max-size: "288MiB" - region-split-size: "192MiB" - region-max-keys: 2880000 - region-split-keys: 1920000 - ``` - -+ To enable Region Merge, add the following configuration in the `roles/pd/vars/default.yml` file. You can also execute the `config set ` command in pd-ctl to enable this feature. - - {{< copyable "" >}} - - ```yaml - schedule: - max-merge-region-size: 20 # Merges Regions smaller that 20 MB. - max-merge-region-keys: 200000 # Merges Regions with less than 20,000 keys. - split-merge-interval: "1h" - merge-schedule-limit: 8 # Controls the speed of merge. Setting this value to 0 will disable Region Merge. - ``` - -### For clusters deployed not using TiDB Ansible - -For TiDB clusters deployed not using TiDB Ansible, use the following methods to set Region size and enable Region Merge: - -+ To modify the Region size, add the following configuration in the `tikv.toml` file and then restart the cluster. - - {{< copyable "" >}} - - ```toml - [coprocessor] - region-max-size = "288MiB" - region-split-size = "192MiB" - region-max-keys = 2880000 - region-split-keys = 1920000 - ``` - -+ To enable Region Merge, add the following configuration in the `pd.toml` file: - - {{< copyable "" >}} - - ```toml - [schedule] - max-merge-region-size = 20 - max-merge-region-keys = 200000 - split-merge-interval = "1h" - merge-schedule-limit = 8 - ``` - - You can also execute the `config set ` command in pd-ctl to enable Region Merge. From 52565848713535c6d90b4e2e23afce0a7b49e8be Mon Sep 17 00:00:00 2001 From: Keke Yi <40977455+yikeke@users.noreply.github.com> Date: Thu, 9 Apr 2020 20:36:37 +0800 Subject: [PATCH 7/7] Update reference/tiflash/tune-performance.md --- reference/tiflash/tune-performance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/tiflash/tune-performance.md b/reference/tiflash/tune-performance.md index 2618150c91975..efda5c98831e9 100644 --- a/reference/tiflash/tune-performance.md +++ b/reference/tiflash/tune-performance.md @@ -6,7 +6,7 @@ category: reference # Tune TiFlash Performance -This document introduces how to tune the performance of TiFlash, including planning machine resources and tuning TiDB parameters +This document introduces how to tune the performance of TiFlash, including planning machine resources and tuning TiDB parameters. ## Plan resources