# Scale Out & In

> - **Objective:** Scale out & in of a TiDB Cluster
> - **Prerequisites:**
>     - background knowledge of TiDB components
>     - AWS account
>     - deployed TiDB cluster
> - **Optionality:** Required
> - **Estimated time:** 15min

## Scale Out

To scale the TiDB cluster, modify the `default_cluster_tikv_count` or `default_cluster_tidb_count` variable in the `variables.tf` file to the desired count. For example, to scale out the TiDB nodes, you can modify the number of TiDB instances from 2 to 4:

```
default_cluster_tidb_count = 4
```

Then apply the change in Terraform to scale out the number of the corresponding component nodes:

```{.bash .copyable}
terraform apply
```

After the nodes scale out, modify the `spec.tidb.replicas` in `TidbCluster` to scale out the Pod:

```{.bash .copyable}
kubectl edit tc ${cluster_name} -n ${namespace}
```

Scaling out needs a few minutes to complete. Monitor the progress using this command:

```{.bash .copyable}
watch kubectl --kubeconfig get po -n ${namespace}
```

## Scale In

> **Note**
> 
> Currently, scaling in TiKV is **not** supported because it's not possible to determine which node to scale in.

You can scale in the number of TiDB nodes participating in the cluster by editing the `TidbCluster` (`tc`) CRD using `kubectl edit`, but that won't cause Terraform to remove the physical nodes (meaning that they will continue to incur costs).
