TiDB TPC-C 性能对比测试报告 - v6.0.0 对比 v5.4.0

测试概况

本次测试对比了 TiDB v6.0.0 和 v5.4.0 在 OLTP 场景下的 TPC-C 性能表现。结果显示,v6.0.0 相比于 v5.4.0 在 TPC-C 性能提升了 24.20%。

测试环境 (AWS EC2)

硬件配置

服务类型 EC2 类型 实例数
PD m5.xlarge 3
TiKV i3.4xlarge 3
TiDB c5.4xlarge 3
TPC-C c5.9xlarge 1

软件版本

服务类型 软件版本
PD v5.4.0、v6.0.0
TiDB v5.4.0、v6.0.0
TiKV v5.4.0、v6.0.0
TiUP 1.9.3
HAProxy 2.5.0

配置参数

两个版本使用同样的配置

TiDB 参数配置

  1. log.level: "error"
  2. prepared-plan-cache.enabled: true
  3. tikv-client.max-batch-wait-time: 2000000

TiKV 参数配置

  1. pessimistic-txn.pipelined: true
  2. raftdb.allow-concurrent-memtable-write: true
  3. raftdb.max-background-jobs: 4
  4. raftstore.apply-max-batch-size: 2048
  5. raftstore.apply-pool-size: 3
  6. raftstore.store-max-batch-size: 2048
  7. raftstore.store-pool-size: 3
  8. readpool.storage.normal-concurrency: 10
  9. rocksdb.max-background-jobs: 8
  10. server.grpc-concurrency: 6

TiDB 全局变量配置

  1. set global tidb_hashagg_final_concurrency=1;
  2. set global tidb_hashagg_partial_concurrency=1;
  3. set global tidb_enable_async_commit = 1;
  4. set global tidb_enable_1pc = 1;
  5. set global tidb_guarantee_linearizability = 0;
  6. set global tidb_enable_clustered_index = 1;

HAProxy 配置 - haproxy.cfg 文件

更多有关 HAProxy 在 TiDB 上的使用,可参阅 HAProxy 在 TiDB 中的最佳实践

  1. global # 全局配置。
  2. pidfile /var/run/haproxy.pid # 将 HAProxy 进程的 PID 写入 pidfile。
  3. maxconn 4000 # 每个 HAProxy 进程所接受的最大并发连接数。
  4. user haproxy # 同 UID 参数。
  5. group haproxy # 同 GID 参数,建议使用专用用户组。
  6. nbproc 64 # 在后台运行时创建的进程数。在启动多个进程转发请求时,确保该值足够大,保证 HAProxy 不会成为瓶颈。
  7. daemon # 让 HAProxy 以守护进程的方式工作于后台,等同于命令行参数“-D”的功能。当然,也可以在命令行中用“-db”参数将其禁用。
  8. defaults # 默认配置。
  9. log global # 日志继承全局配置段的设置。
  10. retries 2 # 向上游服务器尝试连接的最大次数,超过此值便认为后端服务器不可用。
  11. timeout connect 2s # HAProxy 与后端服务器连接超时时间。如果在同一个局域网内,可设置成较短的时间。
  12. timeout client 30000s # 客户端与 HAProxy 连接后,数据传输完毕,即非活动连接的超时时间。
  13. timeout server 30000s # 服务器端非活动连接的超时时间。
  14. listen tidb-cluster # 配置 database 负载均衡。
  15. bind 0.0.0.0:3390 # 浮动 IP 和 监听端口。
  16. mode tcp # HAProxy 要使用第 4 层的传输层。
  17. balance leastconn # 连接数最少的服务器优先接收连接。`leastconn` 建议用于长会话服务,例如 LDAP、SQL、TSE 等,而不是短会话协议,如 HTTP。该算法是动态的,对于启动慢的服务器,服务器权重会在运行中作调整。
  18. server tidb-1 10.9.18.229:4000 check inter 2000 rise 2 fall 3 # 检测 4000 端口,检测频率为每 2000 毫秒一次。如果 2 次检测为成功,则认为服务器可用;如果 3 次检测为失败,则认为服务器不可用。
  19. server tidb-2 10.9.39.208:4000 check inter 2000 rise 2 fall 3
  20. server tidb-3 10.9.64.166:4000 check inter 2000 rise 2 fall 3

测试方案

  1. 通过 TiUP 部署 TiDB v6.0.0 和 v5.4.0。
  2. 创建数据库 tpcc:create database tpcc;
  3. 通过 tiup bench 导入 TPC-C 5000 Warehouse 数据:tiup bench tpcc prepare --warehouses 5000 --db tpcc -H 127.0.0.1 -p 4000
  4. 运行 tiup bench tpcc run -U root --db tpcc --host 127.0.0.1 --port 4000 --time 1800s --warehouses 5000 --threads {{thread}} 命令,通过 HAProxy 向 TiDB 加压,每个并发数各测试 30 分钟。
  5. 从结果中提取 New Order 的 tpmC 的数据。

测试结果

v6.0.0 相比 v5.4.0 在 TPC-C 性能上有大幅提升,平均提升了 24.20%

Threads v5.4.0 tpmC v6.0.0 tpmC tpmC 提升 (%)
50 44822.8 54956.6 22.61
100 52150.3 66216.6 26.97
200 57344.9 72116.7 25.76
400 58675 71254.8 21.44

TPC-C