Skip to content

Commit

Permalink
Tiup 5.0: update deploy, upgrade, maintain docs (pingcap#5728)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucklove authored Mar 24, 2021
1 parent fe89109 commit b431590
Show file tree
Hide file tree
Showing 16 changed files with 362 additions and 762 deletions.
16 changes: 8 additions & 8 deletions TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
+ 快速上手
+ [快速上手指南](/quick-start-with-tidb.md)
+ [SQL 基本操作](/basic-sql-operations.md)
+ 部署集群
+ 部署标准集群
+ [软硬件环境需求](/hardware-and-software-requirements.md)
+ [环境与系统配置检查](/check-before-deployment.md)
+ 配置拓扑结构
+ 规划集群拓扑
+ [最小部署拓扑结构](/minimal-deployment-topology.md)
+ [TiFlash 部署拓扑](/tiflash-deployment-topology.md)
+ [TiCDC 部署拓扑](/ticdc-deployment-topology.md)
Expand All @@ -32,11 +32,12 @@
+ [跨机房部署拓扑结构](/geo-distributed-deployment-topology.md)
+ [混合部署拓扑结构](/hybrid-deployment-topology.md)
+ 安装与启动
+ Linux 环境
+ [使用 TiUP 部署(推荐)](/production-deployment-using-tiup.md)
+ [使用 TiUP 离线部署(推荐)](/production-offline-deployment-using-tiup.md)
+ [在 Kubernetes 上部署](https://docs.pingcap.com/zh/tidb-in-kubernetes/stable)
+ [使用 TiUP 部署(推荐)](/production-deployment-using-tiup.md)
+ [在 Kubernetes 上部署](https://docs.pingcap.com/zh/tidb-in-kubernetes/stable)
+ [验证集群状态](/post-installation-check.md)
+ 测试集群性能
+ [用 Sysbench 测试 TiDB](/benchmark/benchmark-tidb-using-sysbench.md)
+ [对 TiDB 进行 TPC-C 测试](/benchmark/benchmark-tidb-using-tpcc.md)
+ 数据迁移
+ [概述](/migration-overview.md)
+ 从 MySQL 迁移至 TiDB
Expand All @@ -50,7 +51,6 @@
+ 运维操作
+ 升级 TiDB 版本
+ [使用 TiUP 升级(推荐)](/upgrade-tidb-using-tiup.md)
+ [使用 TiUP 离线升级(推荐)](/upgrade-tidb-using-tiup-offline.md)
+ [使用 TiDB Operator](https://docs.pingcap.com/zh/tidb-in-kubernetes/v1.1/upgrade-a-tidb-cluster)
+ 扩缩容
+ [使用 TiUP(推荐)](/scale-tidb-using-tiup.md)
Expand All @@ -64,7 +64,7 @@
+ [修改时区](/configure-time-zone.md)
+ [日常巡检](/daily-check.md)
+ [TiFlash 常用运维操作](/tiflash/maintain-tiflash.md)
+ [TiUP 常用运维操作](/maintain-tidb-using-tiup.md)
+ [使用 TiUP 运维集群](/maintain-tidb-using-tiup.md)
+ [在线修改集群配置](/dynamic-config.md)
+ 监控与告警
+ [监控框架概述](/tidb-monitoring-framework.md)
Expand Down
120 changes: 24 additions & 96 deletions benchmark/benchmark-tidb-using-sysbench.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,19 @@ aliases: ['/docs-cn/dev/benchmark/benchmark-tidb-using-sysbench/','/docs-cn/dev/

# 如何用 Sysbench 测试 TiDB

本次测试使用的是 TiDB 3.0 Beta 和 Sysbench 1.0.14。建议使用 Sysbench 1.0 或之后的更新版本,可在 [Sysbench Release 1.0.14 页面](https://github.com/akopytov/sysbench/releases/tag/1.0.14)下载。

## 测试环境

- [硬件要求](/hardware-and-software-requirements.md)

- 参考 [TiDB 部署文档](https://pingcap.com/docs-cn/v3.0/how-to/deploy/orchestrated/ansible/)部署 TiDB 集群。在 3 台服务器的条件下,建议每台机器部署 1 个 TiDB,1 个 PD,和 1 个 TiKV 实例。关于磁盘,以 32 张表、每张表 10M 行数据为例,建议 TiKV 的数据目录所在的磁盘空间大于 512 GB。对于单个 TiDB 的并发连接数,建议控制在 500 以内,如需增加整个系统的并发压力,可以增加 TiDB 实例,具体增加的 TiDB 个数视测试压力而定。

IDC 机器:

| 类别 | 名称 |
|:---- |:---- |
| OS | Linux (CentOS 7.3.1611) |
| CPU | 40 vCPUs, Intel® Xeon® CPU E5-2630 v4 @ 2.20GHz |
| RAM | 128GB |
| DISK | Intel Optane SSD P4800X 375G * 1 |
| NIC | 10Gb Ethernet |
建议使用 Sysbench 1.0 或之后的更新版本,可在 [Sysbench Release 1.0.14 页面](https://github.com/akopytov/sysbench/releases/tag/1.0.14)下载。

## 测试方案

### TiDB 版本信息

| 组件 | GitHash |
|:---- |:---- |
| TiDB | 7a240818d19ae96e4165af9ea35df92466f59ce6 |
| TiKV | e26ceadcdfe94fb6ff83b5abb614ea3115394bcd |
| PD | 5e81548c3c1a1adab056d977e7767307a39ecb70 |

### 集群拓扑

| 机器 IP | 部署实例 |
|:---- |:---- |
| 172.16.30.31 | 3*sysbench |
| 172.16.30.33 | 1\*tidb 1\*pd 1\*tikv |
| 172.16.30.34 | 1\*tidb 1\*pd 1\*tikv |
| 172.16.30.35 | 1\*tidb 1\*pd 1\*tikv |

### TiDB 配置

升高日志级别,可以减少打印日志数量,对 TiDB 的性能有积极影响。开启 TiDB 配置中的 `prepared plan cache`,以减少优化执行计划的开销。具体在 TiDB 配置文件中加入:
升高日志级别,可以减少打印日志数量,对 TiDB 的性能有积极影响。开启 TiDB 配置中的 `prepared plan cache`,以减少优化执行计划的开销。具体在 TiUP 配置文件中加入:

```toml
[log]
level = "error"
[prepared-plan-cache]
enabled = true
```yaml
server_configs:
tidb:
log.level: "error"
prepared-plan-cache.enabled: true
```
### TiKV 配置
Expand All @@ -63,20 +30,20 @@ Default CF : Write CF = 4 : 1
在 TiKV 中需要根据机器内存大小配置 RocksDB 的 block cache,以充分利用内存。以 40 GB 内存的虚拟机部署一个 TiKV 为例,其 block cache 建议配置如下:
```toml
log-level = "error"
[rocksdb.defaultcf]
block-cache-size = "24GB"
[rocksdb.writecf]
block-cache-size = "6GB"
```yaml
server_configs:
tikv:
log-level: "error"
rocksdb.defaultcf.block-cache-size: "24GB"
rocksdb.writecf.block-cache-size: "6GB"
```
对于 3.0 及以后的版本,还可以使用共享 block cache 的方式进行设置:
还可以使用共享 block cache 的方式进行设置:
```toml
log-level = "error"
[storage.block-cache]
capacity = "30GB"
```yaml
server_configs:
tikv:
storage.block-cache.capacity: "30GB"
```
更详细的 TiKV 参数调优请参考 [TiKV 内存参数性能调优](/tune-tikv-memory-performance.md)。
Expand All @@ -85,7 +52,7 @@ capacity = "30GB"
> **注意:**
>
> 此次测试并没有使用如 HAproxy 等负载均衡工具。在 TiDB 单一节点上进行 Sysbench 测试,并把结果相加。负载均衡工具和不同版本参数也会影响性能表现。
> 此文档中的测试并没有使用如 HAproxy 等负载均衡工具。在 TiDB 单一节点上进行 Sysbench 测试,并把结果相加。负载均衡工具和不同版本参数也会影响性能表现。
### Sysbench 配置
Expand Down Expand Up @@ -121,6 +88,10 @@ db-driver=mysql

### 数据导入

> **注意:**
>
> 如果 TiDB 启用了乐观事务模型(默认为悲观锁模式),当发现并发冲突时,会回滚事务。将 `tidb_disable_txn_auto_retry` 设置为 `off` 会开启事务冲突后的自动重试机制,可以尽可能避免事务冲突报错导致 Sysbench 程序退出的问题。
在数据导入前,需要对 TiDB 进行简单设置。在 MySQL 客户端中执行如下命令:

{{< copyable "sql" >}}
Expand All @@ -129,7 +100,7 @@ db-driver=mysql
set global tidb_disable_txn_auto_retry = off;
```

然后退出客户端。TiDB 使用乐观事务模型,当发现并发冲突时,会回滚事务。将 `tidb_disable_txn_auto_retry` 设置为 `off` 会开启事务冲突后的自动重试机制,可以尽可能避免事务冲突报错导致 Sysbench 程序退出的问题。
然后退出客户端。

重新启动 MySQL 客户端执行以下 SQL 语句,创建数据库 `sbtest`

Expand Down Expand Up @@ -204,49 +175,6 @@ sysbench --config-file=config oltp_update_index --tables=32 --table-size=1000000
sysbench --config-file=config oltp_read_only --tables=32 --table-size=10000000 run
```

## 测试结果

测试了数据 32 表,每表有 10M 数据。

对每个 tidb-server 进行了 Sysbench 测试,将结果相加,得出最终结果:

### oltp_point_select

| 类型 | Thread | TPS | QPS | avg.latency(ms) | .95.latency(ms) | max.latency(ms) |
|:---- |:---- |:---- |:---- |:----------------|:----------------- |:---- |
| point_select | 3\*8 | 67502.55 | 67502.55 | 0.36 | 0.42 | 141.92 |
| point_select | 3\*16 | 120141.84 | 120141.84 | 0.40 | 0.52 | 20.99 |
| point_select | 3\*32 | 170142.92 | 170142.92 | 0.58 | 0.99 | 28.08 |
| point_select | 3\*64 | 195218.54 | 195218.54 | 0.98 | 2.14 | 21.82 |
| point_select | 3\*128 | 208189.53 | 208189.53 | 1.84 | 4.33 | 31.02 |

![oltp_point_select](/media/oltp_point_select.png)

### oltp_update_index

| 类型 | Thread | TPS | QPS | avg.latency(ms) | .95.latency(ms) | max.latency(ms) |
|:---- |:---- |:---- |:---- |:----------------|:----------------- |:---- |
| oltp_update_index | 3\*8 | 9668.98 | 9668.98 | 2.51 | 3.19 | 103.88|
| oltp_update_index | 3\*16 | 12834.99 | 12834.99 | 3.79 | 5.47 | 176.90 |
| oltp_update_index | 3\*32 | 15955.77 | 15955.77 | 6.07 | 9.39 | 4787.14 |
| oltp_update_index | 3\*64 | 18697.17 | 18697.17 | 10.34 | 17.63 | 4539.04 |
| oltp_update_index | 3\*128 | 20446.81 | 20446.81 | 18.98 | 40.37 | 5394.75 |
| oltp_update_index | 3\*256 | 23563.03 | 23563.03 | 32.86 | 78.60 | 5530.69 |

![oltp_update_index](/media/oltp_update_index.png)

### oltp_read_only

| 类型 | Thread | TPS | QPS | avg.latency(ms) | .95.latency(ms) | max.latency(ms) |
|:---- |:---- |:---- |:---- |:----------------|:----------------- |:---- |
| oltp_read_only | 3\*8 | 2411.00 | 38575.96 | 9.92 | 20.00 | 92.23 |
| oltp_read_only | 3\*16 | 3873.53 | 61976.50 | 12.25 | 16.12 | 56.94 |
| oltp_read_only | 3\*32 | 5066.88 | 81070.16 | 19.42 | 26.20 | 123.41 |
| oltp_read_only | 3\*64 | 5466.36 | 87461.81 | 34.65 | 63.20 | 231.19 |
| oltp_read_only | 3\*128 | 6684.16 | 106946.59 | 57.29 | 97.55 | 180.85 |

![oltp_read_only](/media/oltp_read_only.png)

## 常见问题

### 在高并发压力下,TiDB、TiKV 的配置都合理,为什么整体性能还是偏低?
Expand Down
Loading

0 comments on commit b431590

Please sign in to comment.