tpcc-mysql 性能測試

tpcc-mysql安裝

Tpcc-mysql通過模擬一個電商的業務,主要包含的業務有新增訂單,庫存查詢,發貨,支付等模塊的測試,用來測試典型的複雜OLTP系統的性能。Tpcc-mysql是percona基於tpcc衍生出來的產品,專用於mysql基準測試。

shell> cd /db/tool/tpcc-mysql/src/
shell> make
cc -w -O2 -g -I. `mysql_config --include`  -c load.c
cc -w -O2 -g -I. `mysql_config --include`  -c support.c
cc load.o support.o `mysql_config --libs_r` -lrt -o ../tpcc_load
cc -w -O2 -g -I. `mysql_config --include`  -c main.c
cc -w -O2 -g -I. `mysql_config --include`  -c spt_proc.c
cc -w -O2 -g -I. `mysql_config --include`  -c driver.c
cc -w -O2 -g -I. `mysql_config --include`  -c sequence.c
cc -w -O2 -g -I. `mysql_config --include`  -c rthist.c
cc -w -O2 -g -I. `mysql_config --include`  -c neword.c
cc -w -O2 -g -I. `mysql_config --include`  -c payment.c
cc -w -O2 -g -I. `mysql_config --include`  -c ordstat.c
cc -w -O2 -g -I. `mysql_config --include`  -c delivery.c
cc -w -O2 -g -I. `mysql_config --include`  -c slev.c
cc main.o spt_proc.o driver.o support.o sequence.o rthist.o neword.o payment.o ordstat.o delivery.o slev.o 
`mysql_config --libs_r` -lrt -o ../tpcc_start

shell> ln -s /db/tool/tpcc-mysql/tpcc_load /usr/local/bin/tpcc_load
shell> ln -s /db/tool/tpcc-mysql/tpcc_start /usr/local/bin/tpcc_start
然後就會在 /db/tool/tpcc-mysql 下生成 tpcc 命令行工具 tpcc_load 、 tpcc_start

make命令會在tpcc-mysql目錄下生成 tpcc 命令行工具 tpcc_load ,tpcc_start
tpcc_load : 提供初始化數據的功能
tpcc_start: 進行壓力測試

shell> tpcc_load --help
*************************************
*** ###easy### TPC-C Data Loader  ***
*************************************

 usage: tpcc_load [server] [DB] [user] [pass] [warehouse]
      OR
        tpcc_load [server] [DB] [user] [pass] [warehouse] [part] [min_wh] [max_wh]

           * [part]: 1=ITEMS 2=WAREHOUSE 3=CUSTOMER 4=ORDERS

Server:    服務器名
DB:    數據庫名
user: 用戶名
pass: 密碼
Warehouse: 倉庫的數量

shell>  tpcc_start --help
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
tpcc_start: invalid option -- '-'
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

-h server_host: 服務器名
-P port : 端口號,默認爲3306
-d database_name: 數據庫名
-u mysql_user :    用戶名
-p mysql_password :    密碼
-w warehouses : 倉庫的數量
-c connections :     線程數,默認爲1
-r warmup_time :     熱身時間,單位:s,默認爲10s ,熱身是爲了將數據加載到內存。
-l running_time : 測試時間,單位:s,默認爲20s
-i report_interval :     指定生成報告間隔時長
-f report_file :     測試結果輸出文件

加載測試數據

shell> mysqladmin -u root -p create tpcc         ##創建數據庫
shell> mysql -u root -p tpcc < create_table.sql  ##創建表
shell> mysql -u root -p tpcc < add_fkey_idx.sql  ##添加外鍵

shell> tpcc_load 127.0.0.1 tpcc root mypass 5   ##單進程加載
*************************************
*** ###easy### TPC-C Data Loader  ***
*************************************
<Parameters>
     [server]: 127.0.0.1
     [port]: 3306
     [DBname]: tpcc
       [user]: root
       [pass]: oracle
  [warehouse]: 5
TPCC Data Load Started...
.
.
.
Loading Orders for D=10, W= 5
.......... 1000
.......... 2000
.......... 3000
Orders Done.

...DATA LOADING COMPLETED SUCCESSFULLY.

shell> ./load.sh tpcc 5   ##單進程加載


對5個數據倉庫,預熱10秒,100個併發連接,運行60秒
shell> tpcc_start -h 127.0.0.1 -d tpcc -u root -p mypass -w 5 -c 100 -r 10 -l 60  -i 10 -f report20141224 -t tr
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
option h with value '127.0.0.1'
option d with value 'tpcc'
option u with value 'root'
option p with value 'mypass'
option w with value '5'
option c with value '100'
option r with value '10'
option l with value '60'
option i with value '10'
option f with value 'report20141224'
option t with value 'tr'
<Parameters>
     [server]: 127.0.0.1
     [port]: 3306
     [DBname]: tcpp
       [user]: root
       [pass]: oracle
  [warehouse]: 5
 [connection]: 100
     [rampup]: 10 (sec.)
    [measure]: 60 (sec.)

RAMP-UP TIME.(10 sec.)

-- 預熱結束,開始進行壓測
MEASURING START.

-- Count   New-Order            Payment         Order-Status        Delivery            Stock-Level
-- #,  sl(l):rt90|max_rt , sl(l):rt90|max_rt ,  sl(l):rt90|max_rt, sl(l):rt90|max_rt,  sl(l):rt90|max_rt

  10, 462(3):4.372|8.759, 455(0):0.901|2.598, 44(0):0.515|0.638, 45(0):4.798|5.277, 46(0):11.478|12.548
  20, 443(2):3.373|10.121, 433(0):0.784|1.917, 45(0):0.684|4.988, 46(0):3.931|6.257, 49(2):19.999|28.975
  30, 441(2):3.362|14.565, 466(1):0.899|12.739, 45(0):0.459|0.468, 44(0):4.697|5.110, 44(0):15.978|17.884
  40, 407(6):5.016|13.801, 392(0):0.765|1.341, 40(0):0.708|1.930, 41(0):4.085|4.382, 37(0):10.870|11.099
  50, 419(0):3.207|3.905, 427(0):1.204|1.936, 43(0):0.428|0.570, 42(0):4.790|5.411, 46(0):11.452|11.507
  60, 436(4):4.247|22.267, 429(0):0.944|1.864, 43(0):0.397|0.597, 45(0):4.182|4.889, 39(0):11.628|11.851

-- 壓測結束
STOPPING 
THREADS....................................................................................................

-- 第一次結果統計
<Raw Results>
  [0] sc:2591  lt:17  rt:0  fl:0 -- New-Order,新訂單業務成功(sc)次數,延遲(lt)次數,重試(rt)次數,失敗(fl)次數
  [1] sc:2601  lt:1  rt:0  fl:0  -- Payment,支付業務統計
  [2] sc:260  lt:0  rt:0  fl:0   -- Order-Status,訂單狀態業務統計,其他同上
  [3] sc:263  lt:0  rt:0  fl:0   -- Delivery,發貨業務統計,其他同上
  [4] sc:259  lt:2  rt:0  fl:0   -- Stock-Level,庫存業務統計,其他同上
 in 60 sec.

-- 第二次統計結果,其他同上
<Raw Results2(sum ver.)>
  [0] sc:2591  lt:17  rt:0  fl:0 
  [1] sc:2601  lt:1  rt:0  fl:0 
  [2] sc:260  lt:0  rt:0  fl:0 
  [3] sc:263  lt:0  rt:0  fl:0 
  [4] sc:259  lt:2  rt:0  fl:0 

<Constraint Check> (all must be [OK])  -- 下面所有業務邏輯結果都必須爲 OK 纔行
 [transaction percentage]
        Payment: 43.41% (>=43.0%) [OK] -- 支付成功次數(sc + lt)必須大於43.0%,否則結果爲NG,而不是OK
   Order-Status: 4.34% (>= 4.0%) [OK]
       Delivery: 4.39% (>= 4.0%) [OK]
    Stock-Level: 4.35% (>= 4.0%) [OK]
 [response time (at least 90% passed)]   -- 響應耗時指標必須超過90%通過纔行
      New-Order: 99.35%  [OK]       #新訂單     late:>=5ms
        Payment: 99.96%  [OK]       #支付       late:>=5ms
   Order-Status: 100.00%  [OK]      #訂單查詢   late:>=5ms
       Delivery: 100.00%  [OK]      #發貨       late:>=80ms
    Stock-Level: 99.23%  [OK]       #庫存       late:>=20ms

<TpmC>
                 2608.000 TpmC   #TpmC結果值(每分鐘事務數,該值是第一次統計結果中的新訂單事務數除以總耗時分鐘數
,例如本例中是:2608/1 = 2608.000)

預定義變量:
爲了能夠清晰的說明以下內容,首先定義一些變量,便於以下的計算和說明。具體如下所示:
success : 執行成功的記錄數
late : 執行延遲的記錄數
pre_success : 上一次執行成功的記錄數
pre_late : 上一次執行失敗的記錄數

根據以上定義的變量,計算相應字段的結果和說明相應字段的含義。
1、時間間隔內成功的事務(包括成功和延遲的事務):sl=success+late-pre_success-pre_late
2、時間間隔內延遲的事務:l=late-pre_late
3、時間間隔內前90%記錄(實際爲99%)的平均響應時間:rt90
4、時間間隔內最大的響應時間:max_rt

整理自網絡

Svoid
2014-12-26

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章