如何对 TiDB 进行 CH-benCHmark 测试

    CH-benCHmark 是包含 TPC-C 和 的混合负载,也是用于测试 HTAP 系统的最常见负载。更多信息,请参考 The mixed workload CH-benCHmark

    在进行 CH-benCHmark 测试前,你需要先部署 TiDB 的 HTAP 组件 。部署 TiFlash 并创建 TiFlash 副本后,对于 TPC-C 联机交易数据,系统将实时同步最新的数据到 TiFlash 组件;TiDB 优化器会自动将 TPC-H 负载的 OLAP 查询下推到 TiFlash MPP 引擎进行高效执行。

    本文使用 作为 CH 测试实现,可以通过 TiUP 命令下载测试程序:

    关于 TiUP Bench 组件的详细用法可参考 。

    导入数据通常是整个 TPC-C 测试中最耗时、也是最容易出问题的阶段。

    1. tiup bench tpcc -H 172.16.5.140 -P 4000 -D tpcc --warehouses 1000 prepare -T 32

    基于不同的机器配置,数据导入过程可能会持续几个小时。如果是小型集群,可以使用较小的 WAREHOUSE 值进行测试。

    数据导入完成后,可以通过命令 tiup bench tpcc -H 172.16.5.140 -P 4000 -D tpcc --warehouses 1000 check 验证数据正确性。

    导入 TPC-H 所需额外的表和视图

    在 shell 中运行 TiUP 命令:

    1. tiup bench ch -H 172.16.5.140 -P 4000 -D tpcc prepare

    日志输出如下:

    部署 TiFlash 后,TiFlash 并不会自动同步 TiKV 数据,你需要执行以下 SQL 语句创建整库的 TiFlash 副本。创建 TiFlash 副本后,系统自动实时同步最新数据到 TiFlash 组件。例如,当集群中部署了两个 TiFlash 节点时,如果将 replica 设置为 2,执行以下 SQL 语句将创建两个 TiFlash 副本。

      1. SELECT * FROM information_schema.tiflash_replica WHERE TABLE_SCHEMA = 'tpcc';

      查询结果中:

      • AVAILABLE 字段表示该表的 TiFlash 副本是否可用。1 代表可用,0 代表不可用。副本状态变为可用之后就不再改变。
      • 字段代表同步进度,进度值在 0 到 1 之间,1 代表 TiFlash 副本已经完成同步。

      为了确保优化器能生成最优的执行计划,请执行以下 SQL 语句提前搜集统计信息:

      以 50 TP 并发,1 AP 并发为例,运行以下测试命令:

      1. tiup bench ch --host 172.16.5.140 -P4000 --warehouses 1000 run -D tpcc -T 50 -t 1 --time 1h

      命令运行过程中,控制台上会持续打印测试结果。例如:

      1. [Current] NEW_ORDER - Takes(s): 10.0, Count: 13524, TPM: 81162.0, Sum(ms): 998317.6, Avg(ms): 73.9, 50th(ms): 71.3, 90th(ms): 100.7, 95th(ms): 113.2, 99th(ms): 159.4, 99.9th(ms): 209.7, Max(ms): 243.3
      2. [Current] ORDER_STATUS - Takes(s): 10.0, Count: 1132, TPM: 6792.7, Sum(ms): 16196.6, Avg(ms): 14.3, 50th(ms): 13.1, 90th(ms): 24.1, 95th(ms): 27.3, 99th(ms): 37.7, 99.9th(ms): 50.3, Max(ms): 52.4
      3. [Current] PAYMENT - Takes(s): 10.0, Count: 12977, TPM: 77861.1, Sum(ms): 773982.0, Avg(ms): 59.7, 50th(ms): 56.6, 90th(ms): 88.1, 95th(ms): 100.7, 99th(ms): 151.0, 99.9th(ms): 201.3, Max(ms): 243.3
      4. [Current] STOCK_LEVEL - Takes(s): 10.0, Count: 1134, TPM: 6806.0, Sum(ms): 31220.9, Avg(ms): 27.5, 50th(ms): 25.2, 90th(ms): 37.7, 95th(ms): 44.0, 99th(ms): 71.3, 99.9th(ms): 117.4, Max(ms): 125.8
      5. [Current] DELIVERY - Takes(s): 10.0, Count: 1167, TPM: 7002.6, Sum(ms): 170712.9, Avg(ms): 146.3, 50th(ms): 142.6, 90th(ms): 192.9, 95th(ms): 209.7, 99th(ms): 251.7, 99.9th(ms): 335.5, Max(ms): 385.9
      6. [Current] ORDER_STATUS - Takes(s): 10.0, Count: 1224, TPM: 7350.6, Sum(ms): 17874.1, Avg(ms): 14.6, 50th(ms): 13.6, 90th(ms): 23.1, 95th(ms): 27.3, 99th(ms): 37.7, 99.9th(ms): 54.5, Max(ms): 60.8
      7. [Current] PAYMENT - Takes(s): 10.0, Count: 12650, TPM: 75901.1, Sum(ms): 761981.3, Avg(ms): 60.3, 50th(ms): 56.6, 90th(ms): 88.1, 95th(ms): 104.9, 99th(ms): 159.4, 99.9th(ms): 218.1, Max(ms): 318.8
      8. [Current] STOCK_LEVEL - Takes(s): 10.0, Count: 1179, TPM: 7084.9, Sum(ms): 32829.8, Avg(ms): 27.9, 50th(ms): 26.2, 90th(ms): 37.7, 95th(ms): 44.0, 99th(ms): 71.3, 99.9th(ms): 100.7, Max(ms): 117.4
      9. [Current] Q12 - Count: 1, Sum(ms): 9945.8, Avg(ms): 9944.7
      10. [Current] Q13 - Count: 1, Sum(ms): 1729.6, Avg(ms): 1729.6
      11. ...

      命令运行结束后,控制台会打印测试统计结果。例如: