TiDB で CH-benchmark テストを実行する方法

このドキュメントでは、CH-benCHmark を使用して TiDB をテストする方法について説明します。

CH-benCHmark は、 TPC-CTPC-Hの両方のテストを含む混合ワークロードです。これは、HTAP システムをテストするための最も一般的なワークロードです。詳細については、 混合ワークロード CH-benchmarkを参照してください。

CH-benCHmark テストを実行する前に、まず TiDB の HTAP コンポーネントであるティフラッシュをデプロイする必要があります。 TiFlash とTiFlash レプリカの作成をデプロイすると、TiKV は TPC-C オンライン トランザクションの最新データをリアルタイムで TiFlash に複製し、TiDB オプティマイザーは OLAP クエリを TPC-H ワークロードから TiFlash の MPP エンジンに自動的にプッシュ ダウンして効率的に実行します。

このドキュメントの CH-benCHmark テストはゴーtpcに基づいて実装されています。次のTiUPのコマンドを使用して、テスト プログラムをダウンロードできます。

tiup install bench

TiUP Bench コンポーネントの詳細な使用法については、 TiUPベンチを参照してください。

データを読み込む

TPC-C データの読み込み

通常、データのロードは、TPC-C テスト全体で最も時間がかかり、問題のある段階です。

1000 の倉庫を例にとると、シェルで次の TiUP コマンドを実行して、データのロードとテストを行うことができます。このドキュメントの172.16.5.1404000を TiDB のホストとポートの値に置き換える必要があることに注意してください。

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

マシンの構成によっては、このロード プロセスに数時間かかる場合があります。クラスタ サイズが小さい場合は、テストに小さいウェアハウス値を使用できます。

データがロードされたら、 tiup bench tpcc -H 172.16.5.140 -P 4000 -D tpcc --warehouses 1000 checkコマンドを実行してデータの正確性を検証できます。

TPC-H に必要な追加のテーブルとビューをロードする

シェルで次の TiUP コマンドを実行します。

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

ログ出力は次のとおりです。

creating nation creating region creating supplier generating nation table generate nation table done generating region table generate region table done generating suppliers table generate suppliers table done creating view revenue1

TiFlash レプリカの作成

TiFlash がデプロイされた後、TiFlash は TiKV データを自動的に複製しません。 tpccデータベースの TiFlash レプリカを作成するには、次の SQL ステートメントを実行する必要があります。指定された TiFlash レプリカが作成されると、TiKV は最新のデータを TiFlash にリアルタイムで自動的に複製します。次の例では、2 つの TiFlash ノードがクラスターにデプロイされ、レプリカ数が 2 に設定されています。

ALTER DATABASE tpcc SET tiflash replica 2;

tpccデータベース内のすべてのテーブルのレプリケーションが完了したかどうかを確認するには、次のステートメントを実行します。このステートメントでは、 WHERE句を使用して、確認するデータベースとテーブルを指定します。すべてのデータベースのレプリケーション ステータスを確認する場合は、ステートメントからWHERE句を削除します。

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

上記のステートメントの結果:

  • AVAILABLEは、特定のテーブルの TiFlash レプリカが使用可能かどうかを示します。 1は利用可能であることを意味し、 0は利用できないことを意味します。レプリカが使用可能になると、このステータスは変更されなくなります。 DDL ステートメントを使用してレプリカの数を変更すると、レプリケーションの進行状況が再計算されます。
  • PROGRESSは、レプリケーションの進行状況を意味します。値は0.01.0です。 1.0は、少なくとも 1 つのレプリカが複製されていることを意味します。

統計を収集する

TiDB オプティマイザが最適な実行計画を確実に生成できるようにするには、次の SQL ステートメントを実行して事前に統計を収集します。

analyze table customer; analyze table district; analyze table history; analyze table item; analyze table new_order; analyze table order_line; analyze table orders; analyze table stock; analyze table warehouse; analyze table nation; analyze table region; analyze table supplier;

テストを実行する

50 TP の同時実行と 1 AP の同時実行を例にとると、次のコマンドを実行してテストを実行します。

go-tpc ch --host 172.16.5.140 -P4000 --warehouses 1000 run -D tpcc -T 50 -t 1 --time 1h

テスト中、テスト結果は継続的にコンソールに出力されます。例えば:

[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 [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 [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 [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 [Current] Q11 - Count: 1, Sum(ms): 3682.9, Avg(ms): 3683.6 [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 [Current] NEW_ORDER - Takes(s): 10.0, Count: 13238, TPM: 79429.5, Sum(ms): 1010795.3, Avg(ms): 76.4, 50th(ms): 75.5, 90th(ms): 104.9, 95th(ms): 117.4, 99th(ms): 159.4, 99.9th(ms): 234.9, Max(ms): 352.3 [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 [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 [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 [Current] Q12 - Count: 1, Sum(ms): 9945.8, Avg(ms): 9944.7 [Current] Q13 - Count: 1, Sum(ms): 1729.6, Avg(ms): 1729.6 ...

テストが終了すると、テストの要約結果が印刷されます。例えば:

Finished: 50 OLTP workers, 1 OLAP workers [Summary] DELIVERY - Takes(s): 3599.7, Count: 501795, TPM: 8363.9, Sum(ms): 63905178.8, Avg(ms): 127.4, 50th(ms): 125.8, 90th(ms): 167.8, 95th(ms): 184.5, 99th(ms): 226.5, 99.9th(ms): 318.8, Max(ms): 604.0 [Summary] DELIVERY_ERR - Takes(s): 3599.7, Count: 14, TPM: 0.2, Sum(ms): 1027.7, Avg(ms): 73.4, 50th(ms): 71.3, 90th(ms): 109.1, 95th(ms): 109.1, 99th(ms): 113.2, 99.9th(ms): 113.2, Max(ms): 113.2 [Summary] NEW_ORDER - Takes(s): 3599.7, Count: 5629221, TPM: 93826.9, Sum(ms): 363758020.7, Avg(ms): 64.6, 50th(ms): 62.9, 90th(ms): 88.1, 95th(ms): 100.7, 99th(ms): 130.0, 99.9th(ms): 184.5, Max(ms): 570.4 [Summary] NEW_ORDER_ERR - Takes(s): 3599.7, Count: 20, TPM: 0.3, Sum(ms): 404.2, Avg(ms): 20.2, 50th(ms): 18.9, 90th(ms): 37.7, 95th(ms): 50.3, 99th(ms): 56.6, 99.9th(ms): 56.6, Max(ms): 56.6 [Summary] ORDER_STATUS - Takes(s): 3599.8, Count: 500318, TPM: 8339.0, Sum(ms): 7135956.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): 385.9 [Summary] PAYMENT - Takes(s): 3599.8, Count: 5380815, TPM: 89684.8, Sum(ms): 269863092.5, Avg(ms): 50.2, 50th(ms): 48.2, 90th(ms): 75.5, 95th(ms): 88.1, 99th(ms): 125.8, 99.9th(ms): 184.5, Max(ms): 1073.7 [Summary] PAYMENT_ERR - Takes(s): 3599.8, Count: 11, TPM: 0.2, Sum(ms): 313.0, Avg(ms): 28.5, 50th(ms): 10.0, 90th(ms): 67.1, 95th(ms): 67.1, 99th(ms): 88.1, 99.9th(ms): 88.1, Max(ms): 88.1 [Summary] STOCK_LEVEL - Takes(s): 3599.8, Count: 500467, TPM: 8341.5, Sum(ms): 13208726.4, Avg(ms): 26.4, 50th(ms): 25.2, 90th(ms): 37.7, 95th(ms): 44.0, 99th(ms): 62.9, 99.9th(ms): 96.5, Max(ms): 570.4 [Summary] STOCK_LEVEL_ERR - Takes(s): 3599.8, Count: 2, TPM: 0.0, Sum(ms): 7.6, Avg(ms): 3.7, 50th(ms): 3.1, 90th(ms): 4.7, 95th(ms): 4.7, 99th(ms): 4.7, 99.9th(ms): 4.7, Max(ms): 4.7 tpmC: 93826.9, efficiency: 729.6% [Summary] Q1 - Count: 11, Sum(ms): 42738.2, Avg(ms): 3885.3 [Summary] Q10 - Count: 11, Sum(ms): 440370.3, Avg(ms): 40034.3 [Summary] Q11 - Count: 11, Sum(ms): 44208.6, Avg(ms): 4018.7 [Summary] Q12 - Count: 11, Sum(ms): 105320.3, Avg(ms): 9574.6 [Summary] Q13 - Count: 11, Sum(ms): 19199.5, Avg(ms): 1745.4 [Summary] Q14 - Count: 11, Sum(ms): 84582.1, Avg(ms): 7689.5 [Summary] Q15 - Count: 11, Sum(ms): 271944.8, Avg(ms): 24722.8 [Summary] Q16 - Count: 11, Sum(ms): 183894.9, Avg(ms): 16718.1 [Summary] Q17 - Count: 11, Sum(ms): 89018.9, Avg(ms): 8092.7 [Summary] Q18 - Count: 10, Sum(ms): 767814.5, Avg(ms): 76777.6 [Summary] Q19 - Count: 10, Sum(ms): 17099.1, Avg(ms): 1709.8 [Summary] Q2 - Count: 11, Sum(ms): 53513.6, Avg(ms): 4865.2 [Summary] Q20 - Count: 10, Sum(ms): 73717.7, Avg(ms): 7372.1 [Summary] Q21 - Count: 10, Sum(ms): 166001.4, Avg(ms): 16601.1 [Summary] Q22 - Count: 10, Sum(ms): 48268.4, Avg(ms): 4827.7 [Summary] Q3 - Count: 11, Sum(ms): 31110.1, Avg(ms): 2828.5 [Summary] Q4 - Count: 11, Sum(ms): 83814.2, Avg(ms): 7619.3 [Summary] Q5 - Count: 11, Sum(ms): 368301.0, Avg(ms): 33483.5 [Summary] Q6 - Count: 11, Sum(ms): 61702.5, Avg(ms): 5608.9 [Summary] Q7 - Count: 11, Sum(ms): 158928.2, Avg(ms): 14446.3

テストが終了したら、 tiup bench tpcc -H 172.16.5.140 -P 4000 -D tpcc --warehouses 1000 checkコマンドを実行してデータの正確性を検証できます。

Playground
新規
登録なしで TiDB の機能をワンストップでインタラクティブに体験できます。
製品
TiDB Cloud
TiDB
価格
PoC お問い合わせ
エコシステム
TiKV
TiFlash
OSS Insight
© 2024 PingCAP. All Rights Reserved.
Privacy Policy.