MySQL 基準測試工具tpcc-mysql使用手冊及報告分析

神諭丶發表於2017-11-03



〇 下載

  1. git clone https://github.com/Percona-Lab/tpcc-mysql.git
  2. cd tpcc-mysql/src && make

make如果成功後,會在tpcc-mysql目錄下生成tpcc_load與tpcc_start兩個工具。

make如果報錯,一般原因是缺少mysql_config環境,報錯形如:

  1. /bin/sh: mysql_config: command not found
  2. load.c:19:19: error: mysql.h: No such file or directory
  3. ………………
  4. ‘MYSQL_TYPE_LONG’ undeclared
  5. ‘MYSQL_TYPE_STRING’ undeclared
  6. ………………
  7. 並還有一些ERROR

  8. 原因是環境變數設定有誤,或缺少mysql_config環境。
  9. 比如此處,設定一下環境變數:
  10. export PATH=$PATH:/data/mysql57/bin/

使

在待測試的例項中建立一個db,名為tpcc:CREATE DATABASE tpcc;

② 匯入一個tpcc-mysql目錄下的表結構mysql -u$user -p$password -h$host < ./tpcc-mysql/create_table.sql

③ load資料:
./tpcc-mysql/tpcc_load -h$host -d tpcc -u$user -p$password -w 1000 > tpcc.load &
當然這樣load很慢,工具配套有一個簡單的並行load資料的指令碼,load.sh:
使用起來也是十分簡單的:

指令碼並不是很完善,需要自行修改指令碼:
將HOST變數為mysql server的host,
將四個-p後加入密碼。
使用如下:

  1. bash load.sh $dbname $warehouse_count
第一個為schema的名字,此處為tpcc,
第二個為warehouse的數量,此處為1000。

並行匯入是基於四個部分進行的,分別為:
[part]: 1=ITEMS 2=WAREHOUSE 3=CUSTOMER 4=ORDERS
通過./tpcc_load --help,結合load.sh就可以理解。

④ 匯入資料結束後,最後加一個index和fk:mysql -u -p < ./tpcc-mysql/add_fkey_idx.sql

⑤ 測試
./tpcc_start -h$host -u$user -p$password -d tpcc -w 1000 -c32 -r300 -l7200 > /data/tpcc.report 2>&1 & 

詳細用法:
Usage: tpcc_start -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -c connections -r warmup_time -l running_time -i report_interval -f report_file -t trx_file

-w 倉庫數量
-c 併發連線數
-r 開始測試前進行warm up的時間,進行預熱後,測試效果更好,老葉建議300秒以上
-l 測試時間
-i 生成報告間隔時長

一般-f和-t無需指定,一般直接重定向拿到報告結果就足夠

〇 報告分析

     [server]: …………
       [port]: 3306
     [DBname]: tpcc
       [user]: root
       [pass]: *******
  [warehouse]: 1000
 [connection]: 32
     [rampup]: 300 (sec.)
    [measure]: 7200 (sec.)

RAMP-UP TIME.(300 sec.)

MEASURING START.

  10, trx: 1670, 95%: 120.954, 99%: 143.328, max_rt: 291.917, 1675|207.554, 168|164.157, 167|745.408, 168|875.570
  20, trx: 1656, 95%: 128.301, 99%: 150.585, max_rt: 229.172, 1650|102.471, 165|121.764, 165|569.108, 163|737.483
  30, trx: 1679, 95%: 129.072, 99%: 151.535, max_rt: 197.850, 1682|103.436, 168|80.130, 168|658.822, 170|686.441
  40, trx: 1662, 95%: 126.926, 99%: 147.551, max_rt: 182.245, 1656|122.172, 167|97.329, 167|567.806, 164|717.234
  50, trx: 1650, 95%: 130.041, 99%: 151.807, max_rt: 201.568, 1657|124.149, 164|145.663, 164|660.545, 167|683.961
  60, trx: 1659, 95%: 127.841, 99%: 148.926, max_rt: 189.087, 1653|107.867, 166|90.284, 165|535.922, 168|690.396
  ……………………………………………………………………………………………………

STOPPING THREADS................................

10秒列印一次報告。
trx:1670:在給定間隔時間內(此處為10秒,下同)新產生的交易訂單,越高越好。
95%: 120.954:在給定間隔時間內,95%以上筆訂單,新產生的響應時間,越低越好。
99%: 143.328:給定間隔時間內,99%以上筆訂單,新產生的響應時間,越低越好。
max_rt: 291.917:在給定間隔時間內,產生訂單最長的響應時間
1675|207.554, 168|164.157, 167|745.408, 168|875.570:其他型別的事務吞吐量和最大響應時間。


  [0] sc:5 lt:1169114  rt:0  fl:0 avg_rt: 88.2 (5)
  [1] sc:15 lt:1168760  rt:0  fl:0 avg_rt: 35.1 (5)
  [2] sc:1597 lt:115317  rt:0  fl:0 avg_rt: 24.3 (5)
  [3] sc:0 lt:116913  rt:0  fl:0 avg_rt: 318.2 (80)
  [4] sc:0 lt:116914  rt:0  fl:0 avg_rt: 477.7 (20)
 in 7200 sec.

-- 0代表新訂單,1代表支付訂單,2代表訂單狀態業務,3代表發貨,4代表庫存
-- sc:success成功,lt:late延遲,rt:retry重試,fl:failure失敗,avg_rt:平均響應時間
-- 可以看出此次測試的mysql server幾乎完全無法滿足虛擬的tpcc業務。

-- 第二次統計結果
  [0] sc:5  lt:1169123  rt:0  fl:0
  [1] sc:15  lt:1169116  rt:0  fl:0
  [2] sc:1597  lt:115317  rt:0  fl:0
  [3] sc:0  lt:116913  rt:0  fl:0
  [4] sc:0  lt:116914  rt:0  fl:0

(all must be [OK]) -- 以下邏輯均需要ok才可通過
 [transaction percentage]
        Payment: 43.47% (>=43.0%) [OK] -- 支付成功次數
   Order-Status: 4.35% (>= 4.0%) [OK] -- 訂單
       Delivery: 4.35% (>= 4.0%) [OK] -- 發貨
    Stock-Level: 4.35% (>= 4.0%) [OK] -- 庫存
 [response time (at least 90% passed)] -- 響應耗時,需要90%+訂單通過指標,才會成為OK
      New-Order: 0.00%  [NG] *
        Payment: 0.00%  [NG] *
   Order-Status: 1.37%  [NG] *
       Delivery: 0.00%  [NG] *
    Stock-Level: 0.00%  [NG] *
-- 這裡再顯示我測試的mysql server是“通過”的。


                 9742.658 TpmC -- 該值為每分鐘交易transaction數,為第一次產生的結果數/執行分鐘=1169114/120



參考文
https://github.com/Percona-Lab/tpcc-mysql


作者微信公眾號(持續更新)


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29773961/viewspace-2146789/,如需轉載,請註明出處,否則將追究法律責任。

相關文章