文档目录

TiDB Sysbench 性能对比测试报告 - v4.0 对比 v3.0

测试目的

测试对比 TiDB v4.0 和 v3.0 在 OLTP 场景下的性能。

测试环境 (AWS EC2)

硬件配置

服务类型EC2 类型实例数
PDm5.xlarge3
TiKVi3.4xlarge3
TiDBc5.4xlarge3
Sysbenchm5.4xlarge1

软件版本

服务类型软件版本
PD3.0、4.0
TiDB3.0、4.0
TiKV3.0、4.0
Sysbench1.0.20

参数配置

TiDB v3.0 参数配置

log.level: “error”
performance.max-procs: 20
prepared-plan-cache.enabled: true
tikv-client.max-batch-wait-time: 2000000

TiKV v3.0 参数配置

storage.scheduler-worker-pool-size: 5
raftstore.store-pool-size: 3
raftstore.apply-pool-size: 3
rocksdb.max-background-jobs: 3
raftdb.max-background-jobs: 3
raftdb.allow-concurrent-memtable-write: true
server.grpc-concurrency: 6
readpool.storage.normal-concurrency: 10
readpool.coprocessor.normal-concurrency: 5

TiDB v4.0 参数配置

log.level: “error”
performance.max-procs: 20
prepared-plan-cache.enabled: true
tikv-client.max-batch-wait-time: 2000000

TiKV v4.0 参数配置

storage.scheduler-worker-pool-size: 5
raftstore.store-pool-size: 3
raftstore.apply-pool-size: 3
rocksdb.max-background-jobs: 3
raftdb.max-background-jobs: 3
raftdb.allow-concurrent-memtable-write: true
server.request-batch-enable-cross-command: false
server.grpc-concurrency: 6
readpool.unifiy-read-pool: true
readpool.unified.min-thread-count: 5
readpool.unified.max-thread-count: 20
readpool.storage.normal-concurrency: 10
pessimistic-txn.pipelined: true

全局变量配置

set global tidb_hashagg_final_concurrency=1;
set global tidb_hashagg_partial_concurrency=1;
set global tidb_disable_txn_auto_retry=0;

测试方案

  1. 通过 TiUP 部署 TiDB v4.0 和 v3.0。
  2. 通过 Sysbench 导入 16 张表,每张表有 1000 万行数据。
  3. 分别对每个表执行 analyze table 命令。
  4. 备份数据,用于不同并发测试前进行数据恢复,以保证每次数据一致。
  5. 启动 Sysbench 客户端,进行 point_selectread_writeupdate_indexupdate_non_index 测试。通过 AWS NLB 向 TiDB 加压,单轮预热 1 分钟,测试 5 分钟。
  6. 每轮完成后停止集群,使用之前的备份的数据覆盖,再启动集群。

准备测试数据

执行以下命令来准备测试数据:

sysbench oltp_common \
    --threads=16 \
    --rand-type=uniform \
    --db-driver=mysql \
    --mysql-db=sbtest \
    --mysql-host=$aws_nlb_host \
    --mysql-port=$aws_nlb_port \
    --mysql-user=root \
    --mysql-password=password \
    prepare --tables=16 --table-size=10000000

执行测试命令

执行以下命令来执行测试:

sysbench $testname \
    --threads=$threads \
    --time=300 \
    --report-interval=1 \
    --rand-type=uniform \
    --db-driver=mysql \
    --mysql-db=sbtest \
    --mysql-host=$aws_nlb_host \
    --mysql-port=$aws_nlb_port \
    run --tables=16 --table-size=10000000

测试结果

Point Select 性能

Threadsv3.0 QPSv3.0 95% latency (ms)v4.0 QPSv4.0 95% latency (ms)QPS 提升
150117085.7011.667118165.13571.6080.92%
300200621.44712.615207774.08592.0323.57%
600283928.93234.569320673.3423.30412.94%
900343218.26246.686383913.38554.65211.86%
1200347200.23668.092408929.43726.31817.78%
1500366406.276710.562418268.88567.98514.15%

v4.0 对比 v3.0,Point Select 性能提升了 14%。

Point Select

Update Non-index 性能

Threadsv3.0 QPSv3.0 95% latency (ms)v4.0 QPSv4.0 95% latency (ms)QPS 提升
15015446.4102411.44616954.3997110.8449.76%
30022276.1557217.31924364.4468916.7069.37%
60028784.8835329.19431635.7083328.1629.90%
90032194.1554842.61135787.6607838.94211.16%
120033954.6911458.92338552.6315851.01813.54%
150035412.003274.46440859.6375562.19315.38%

v4.0 对比 v3.0,Update Non-index 性能提升了 15%。

Update Non-index

Update Index 性能

Threadsv3.0 QPSv3.0 95% latency (ms)v4.0 QPSv4.0 95% latency (ms)QPS 提升
15011164.4057116.70611954.7363516.4087.08%
30014460.9805728.16215243.4089928.1625.41%
60017112.7303653.8518535.0751550.1078.31%
90018233.8342686.00220339.690170.54811.55%
120018622.50283127.80521390.2512294.10414.86%
150018980.34447170.47922359.996114.71717.81%

v4.0 对比 v3.0,Update Index 性能提升了 17%。

Update Index

Read Write 性能

Threadsv3.0 QPSv3.0 95% latency (ms)v4.0 QPSv4.0 95% latency (ms)QPS 提升
15043768.3363371.8353912.6370559.99323.18%
30055655.63589121.08571327.2133697.55528.16%
60064642.96992223.34484487.75483176.73130.70%
90068947.25293325.98490177.94612257.9530.79%
120071334.80099434.82992779.71507344.07830.06%
150072069.9115580.01795088.50812434.82931.94%

v4.0 对比 v3.0,Read Write 性能提升了 31%。

Read Write