前言
首先我們需要知道tpcc-mysql是干什么的。TPC-C是專門針對聯機交易處理系統(OLTP系統)的規范,一般情況下我們也把這類系統稱為業務處理系統。tpcc-mysql是percona基於TPC-C(下面簡寫成TPCC)衍生出來的產品,專用於MySQL基准測試。
Tpcc工具結構
create_table.sql:創建所需的數據庫表,共9個表
add_fkey_idx.sql:創建索引和外鍵
drop_cons.sql:刪除約束
查看可得tpcc1000庫中共有9個表。
New-Order:新訂單,主要對應 new_orders 表
Payment:支付,主要對應 orders、history 表
Order-Status:訂單狀態,主要對應 orders、order_line 表
Delivery:發貨,主要對應 order_line 表
Stock-Level:庫存,主要對應 stock 表
其他相關表:
客戶:主要對應 customer 表
地區:主要對應 district 表
商品:主要對應 item 表
倉庫:主要對應 warehouse 表
它們的關系:
測試結果分析
(測試過程可見上一篇博客 tpcc-mysql的安裝與使用
root@iZj6c9c6vaqj1i0a9j7h78Z:/home/admin/tpcc-mysql# ./tpcc_start -h 127.0.0.1 -p 3306 -d tpcc1000 -u root -p "123123" -w 10 -c 10 -r 100 -l 300 -i 20*************************************** *** ###easy### TPC-C Load Generator *** *************************************** option h with value '127.0.0.1' option p with value '3306' option d with value 'tpcc1000' option u with value 'root' option p with value '123123' option w with value '10' //倉庫數,必須和tpcc_load一致 option c with value '10' //連接數,可認為是線程數 option r with value '100' //預熱時間, option l with value '300' //測試執行時間 option i with value '20' //產生報告的時間間隔 <Parameters> [server]: 127.0.0.1 [port]: 3306 [DBname]: tpcc1000 [user]: root [pass]: 123123 [warehouse]: 10 [connection]: 10 [rampup]: 100 (sec.) [measure]: 300 (sec.)
每20秒輸出一次測壓數據
RAMP-UP TIME.(100 sec.) //預熱時間 MEASURING START. 20, trx: 1365, 95%: 149.731, 99%: 192.421, max_rt: 375.631, 1366|268.017, 136|94.819, 135|602.898, 137|623.414 40, trx: 1327, 95%: 155.906, 99%: 201.499, max_rt: 317.556, 1325|253.945, 133|77.330, 134|546.059, 133|349.548 60, trx: 1311, 95%: 159.541, 99%: 209.119, max_rt: 395.578, 1313|351.806, 131|91.413, 130|647.841, 131|353.075 80, trx: 1317, 95%: 155.766, 99%: 195.498, max_rt: 317.046, 1318|223.747, 133|140.812, 133|455.009, 131|322.756 100, trx: 1308, 95%: 155.812, 99%: 187.812, max_rt: 288.880, 1307|180.816, 130|72.554, 130|494.693, 131|345.204 120, trx: 1303, 95%: 159.493, 99%: 197.853, max_rt: 279.193, 1305|167.328, 131|148.294, 130|529.679, 131|335.480 140, trx: 1312, 95%: 159.780, 99%: 212.272, max_rt: 313.500, 1313|228.049, 131|87.855, 132|649.486, 130|318.453 160, trx: 1289, 95%: 160.980, 99%: 198.031, max_rt: 258.698, 1290|203.181, 129|144.156, 129|522.998, 129|372.766 180, trx: 1281, 95%: 160.307, 99%: 191.330, max_rt: 278.490, 1282|148.655, 128|92.722, 129|589.544, 128|352.993 200, trx: 1261, 95%: 166.868, 99%: 201.258, max_rt: 306.342, 1257|177.165, 126|133.080, 125|427.867, 126|295.709 220, trx: 1308, 95%: 153.728, 99%: 186.914, max_rt: 275.757, 1306|243.364, 130|62.822, 131|477.343, 133|367.932 240, trx: 1286, 95%: 157.359, 99%: 196.731, max_rt: 304.550, 1291|135.553, 129|80.425, 129|440.484, 128|411.228 260, trx: 1286, 95%: 162.627, 99%: 204.905, max_rt: 248.939, 1287|209.698, 129|104.292, 128|490.073, 128|321.475 280, trx: 1298, 95%: 162.919, 99%: 208.806, max_rt: 320.564, 1291|157.251, 130|76.880, 130|572.787, 129|329.122 300, trx: 1290, 95%: 161.173, 99%: 199.578, max_rt: 378.012, 1296|177.117, 129|129.114, 130|489.317, 129|378.575 STOPPING THREADS..........
分析:
- 以逗號分隔,共6列
- 第一列,上面設置的時間間隔,20秒
- 第二列, 20秒內執行新訂單交易次數,13651次,即這段時間內的吞吐量
- 第三列,95% 新訂單交易平均響應時間,149.731秒
- 第四列,99% 新訂單交易平均響應時間,192.421秒
- 第五列,新訂單交易最長響應時間為375.631秒
- 第五列,支付業務的結果,吞吐量|最大相應時間
- 第六列,發貨業務的結果
- 第六列,庫存業務的結果
<Raw Results> //第一次統計結果 [0] sc:0 lt:19542 rt:0 fl:0 avg_rt: 110.7 (5) //新訂單 [1] sc:253 lt:19294 rt:0 fl:0 avg_rt: 36.8 (5) //支付 [2] sc:563 lt:1392 rt:0 fl:0 avg_rt: 21.6 (5) //訂單查詢 [3] sc:0 lt:1955 rt:0 fl:0 avg_rt: 316.7 (80) //發貨 [4] sc:18 lt:1936 rt:0 fl:0 avg_rt: 233.9 (20) //庫存 in 300 sec. <Raw Results2(sum ver.)> //第二次統計結果 [0] sc:0 lt:19542 rt:0 fl:0 [1] sc:253 lt:19294 rt:0 fl:0 [2] sc:563 lt:1392 rt:0 fl:0 [3] sc:0 lt:1955 rt:0 fl:0 [4] sc:18 lt:1936 rt:0 fl:0
分析:
匯總各種業務各狀態的數據量
- sc: success, 操作成功的數量
- rt: retry, 操作重試的數量
- fl: failure,操作失敗的數量
- avg_rt,平均重試次數
<Constraint Check> (all must be [OK]) [transaction percentage] //每種交易的占比 Payment: 43.48% (>=43.0%) [OK] //支付成功次數(上述統計結果中 sc + lt) 必須大於43.0%,否則結果為NG,而不是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)] //各種交易的響應時間 New-Order: 0.00% [NG] * //正常情況一下5個都應是[OK],我用的阿里雲1G1h比較辣雞 Payment: 1.29% [NG] * Order-Status: 28.80% [NG] * Delivery: 0.00% [NG] * Stock-Level: 0.92% [NG] * <TpmC> 3908.400 TpmC //TpmC結果值(每分鍾事務數,該值是第一次統計結果中的新訂單事務數除以總耗時分鍾數,例如本例中是:19542/5=3908.4)
//tpmC值在國內外被廣泛用於衡量計算機系統的事務處理能力
如果您將輸出結果導入到了文件,例如
./tpcc_start -h 127.0.0.1 -p 3306 -d tpcc1000 -u root -p "123456" -w 10 -c 10 -r 100 -l 300 -i 20 -f /var/log/tpcc_mysql.log -t /var/log/tpcc_mysql.rtx
tpcc_mysql.log的內容如下:
0 101.848
0 168.824
0 258.733
0 257.668
0 268.181
......
280 89.286 //280表示timestamp,89.286表示當前新訂單業務耗時89.286s
280 106.604
280 111.706
300 54.267
300 73.795
300 73.921
tpcc_mysql.rtx的內容如下:
t_num: 6 finish: 1555510718 176127461 start: 1555510718 111539482 t_num: 2 finish: 1555510718 226665914 start: 1555510718 147639779 t_num: 0 finish: 1555510718 229816369 start: 1555510718 135469427 t_num: 4 finish: 1555510718 234458797 start: 1555510718 161088595 t_num: 1 finish: 1555510718 248017799 start: 1555510718 149352990 t_num: 8 finish: 1555510718 252816208 start: 1555510718 163539810 t_num: 9 finish: 1555510718 280146373 start: 1555510718 173552637 t_num: 6 finish: 1555510718 287838904 start: 1555510718 176143349
......
分析:
t_num表示第幾個線程
start表示這筆新訂單發送的起始時間,finish表示訂單的結束時間,注意這個時間指的是占用CPU時間,其實訂單完成時間很大一部分消耗在磁盤的IO處理上。
除了MySQL的輸出日志之外,還需要關心系統的性能指標,因此需要借助iostat
、vmstat
等系統工具,查看系統的性能特征。scripts中有很多工具腳本(不會用555)
參考鏈接:
1. tpcc-mysql安裝、使用、結果解讀 https://yq.aliyun.com/articles/178251
2. tpcc-mysql使用及輸出結果解讀 https://blog.csdn.net/cnhome/article/details/42420869
3. 測試結果圖表化 https://www.hi-linux.com/posts/38534.html