## Module 4: Scale Out The Storage Layer

Scale out the storage layer while the `sysbench` workload is running.

### Step 1. Open a new terminal (Terminal 2) and log into monitor1_address

+ Click [Terminal 2](ssh://monitor1-ssh#2) to open a new terminal connected to the virtual machine assigned for your hands-on lab.

### Step 2. Run test workload

+ Run `sysbench` workload in [Terminal 2](ssh://monitor1-ssh#2). While the workload is running, proceed to the next step, do not wait for the workload to complete.

   ```bash
   sysbench \
    --config-file=sysbench_config oltp_read_only \
    --tables=6 \
    --table-size=1000000 run
   ```

   ```output
   sysbench 1.0.17 (using bundled LuaJIT 2.1.0-beta2)

   Running the test with following options:
   Number of threads: 14
   Report intermediate results every 5 second(s)
   Initializing random number generator from current time

   Initializing worker threads...

   Threads started!
   ...
   ```

### Step 3. Add one TiKV server to the cluster

+ Switch back to [Terminal 1](ssh://monitor1-ssh#1). Scale out the storage layer by adding 1 TiKV server.

   ```bash
   cat scale-out-tikv.yaml
   ```

   ```output
   tikv_servers:
     - host: 10.90.1.245
       port: 20160
       status_port: 20180
   ```

   ```bash
   ~/.tiup/bin/tiup cluster scale-out tidb-demo scale-out-tikv.yaml --user ec2-user -i ~/.ssh/pe-class-key-${LAB:REGION_NAME}.pem -y
   ```

   ```output
   ...
   Scaled cluster `tidb-demo` out successfully
   ```

### Step 4. Check TiDB cluster status

+ Verify there are 4 `tikv` servers in the TiDB cluster now, you scaled TiKV layer size from 3 to 4.

   ```bash
   ~/.tiup/bin/tiup cluster display tidb-demo
   ```

   ```output
   Cluster type:       tidb
   Cluster name:       tidb-demo
   Cluster version:    v${LAB:TIDB_VERSION}
   Deploy user:        ec2-user
   SSH type:           builtin
   Dashboard URL:      http://35.91.126.63:2379/dashboard
   Grafana URL:        http://10.90.4.204:3000
   ID                 Role          Host         Ports        OS/Arch       Status  Data Dir                      Deploy Dir
   --                 ----          ----         -----        -------       ------  --------                      ----------
   10.90.4.204:9093   alertmanager  10.90.4.204  9093/9094    linux/x86_64  Up      /tidb-data/alertmanager-9093  /tidb-deploy/alertmanager-9093
   10.90.4.204:3000   grafana       10.90.4.204  3000         linux/x86_64  Up      -                             /tidb-deploy/grafana-3000
   10.90.3.89:2379    pd            10.90.3.89   2379/2380    linux/x86_64  Up|L    /tidb-data/pd-2379            /tidb-deploy/pd-2379
   10.90.4.204:9090   prometheus    10.90.4.204  9090/12020   linux/x86_64  Up      /tidb-data/prometheus-9090    /tidb-deploy/prometheus-9090
   10.90.1.48:4000    tidb          10.90.1.48   4000/10080   linux/x86_64  Up      -                             /tidb-deploy/tidb-4000
   10.90.1.74:4000    tidb          10.90.1.74   4000/10080   linux/x86_64  Up      -                             /tidb-deploy/tidb-4000
   10.90.1.103:20160  tikv          10.90.1.103  20160/20180  linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
   10.90.1.245:20160  tikv          10.90.1.245  20160/20180  linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
   10.90.1.30:20160   tikv          10.90.1.30   20160/20180  linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
   10.90.1.34:20160   tikv          10.90.1.34   20160/20180  linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
   10.90.4.204:6000   tiproxy       10.90.4.204  6000/3080    linux/x86_64  Up      -                             /tidb-deploy/tiproxy-6000
   Total nodes: 11
   ```

### Step 5. Verify that the workload is not affected by the storage layer scale-out

- Switch to [Terminal 2](ssh://monitor1-ssh#2), observe and confirm that the scaling out operation did not interrupt the workload.
