Scale TiDB in Kubernetes
This document introduces how to horizontally and vertically scale a TiDB cluster in Kubernetes.
Horizontal scaling
Horizontally scaling TiDB means that you scale TiDB out or in by adding or remove nodes in your pool of resources. When you scale a TiDB cluster, PD, TiKV, and TiDB are scaled out or in sequentially according to the values of their replicas. Scaling out operations add nodes based on the node ID in ascending order, while scaling in operations remove nodes based on the node ID in descending order.
Horizontal scaling operations
To perform a horizontal scaling operation:
Modify
pd.replicas
,tidb.replicas
,tikv.replicas
in thevalue.yaml
file of the cluster to a desired value.Run the
helm upgrade
command to scale out or in:helm upgrade <release-name> pingcap/tidb-cluster -f values.yaml --version=<chart_version>View the cluster's scaling status:
watch kubectl -n <namespace> get pod -o wideWhen the number of Pods for all components reaches the preset value and all components go to the
Running
state, the horizontal scaling is completed.
Vertical scaling
Vertically scaling TiDB means that you scale TiDB up or down by increasing or decreasing the limit of resources on the node. Vertically scaling is essentially the rolling update of the nodes.
Vertical scaling operations
To perform a vertical scaling operation:
Modify
tidb.resources
,tikv.resources
,pd.resources
in thevalues.yaml
file to a desired value.Run the
helm upgrade
command to upgrade:helm upgrade <release-name> pingcap/tidb-cluster -f values.yaml --version=<chart_version>View the progress of the upgrade:
watch kubectl -n <namespace> get pod -o wideWhen all Pods are rebuilt and in the
Running
state, the vertical scaling is completed.