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

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