tpcc-mysql使用手册_tpcc-mysql的使用

1、tpcc-mysql的业务逻辑及其相关的几个表作用:

New-Order:新订单,一次完整的订单事务,几乎涉及到全部表

Payment:支付,主要对应 orders、history 表

Order-Status:订单状态,主要对应 orders、order_line 表

Delivery:发货,主要对应 order_line 表

Stock-Level:库存,主要对应 stock 表

其它表说明:

客户:主要对应 customer 表

地区:主要对应 district 表

商品:主要对应 item 表

仓库:主要对应 warehouse 表

2、初始化测试库,先创建一个测试库sampson,并在测试库中创建表,即执行create_table.sql

[root@localhost tpcc-mysql]# mysql -uroot -p -S /tmp/mysql_3306.sock -e 'create database sampson'

Enter password:

[root@localhost tpcc-mysql]# mysql -uroot -p -S /tmp/mysql_3306.sock sampson < ./create_table.sql

Enter password:

[root@localhost tpcc-mysql]# mysql -uroot -p -S /tmp/mysql_3306.sock -e 'show tables from sampson'

Enter password:

+-------------------+

| Tables_in_sampson |

+-------------------+

| customer          |

| district          |

| history           |

| item              |

| new_orders        |

| order_line        |

| orders            |

| stock             |

| warehouse         |

+-------------------+

3、灌入测试数据

执行下面的命令,开始灌入测试数据:(本人的是虚拟机,仓库数就弄了10,省得压死了,哈哈)

[root@localhost tpcc-mysql]# ./tpcc_load 127.0.0.1:3306 sampson root mysql 10

*************************************

*** ###easy### TPC-C Data Loader  ***

*************************************

[server]: 127.0.0.1

[port]: 3306

[DBname]: sampson

[user]: root

[pass]: mysql

[warehouse]: 10

TPCC Data Load Started...

... ...

真实测试场景中,仓库数一般不建议少于100个,视服务器硬件配置而定,如果是配备了SSD或者PCIE SSD这种高IOPS设备的话,建议最少不低于1000个。仓库越多,造数据的时间越长,需要耐心等待。

【在这里,需要注意的是 tpcc 默认会读取 /var/lib/mysql/mysql.sock 这个socket 文件。因此,如果你的 socket 文件不在相应路径的话,可以做个软连接,或者通过TCP/IP的方式连接测试服务器-----注:未对socket做软连接,也未报错】

当造数据完成后,会有提示:...DATA LOADING COMPLETED SUCCESSFULLY.

4、进行TPCC测试以及结果解读

tpcc_start 工具用于tpcc压测,其用法如下:

[root@localhost tpcc-mysql]# ./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

选项说明:

-w 指定仓库数量

-c 指定并发连接数

-r 指定开始测试前进行warmup的时间,进行预热后,测试效果更好

-l 指定测试持续时间

-i 指定生成报告间隔时长

-f 指定生成的报告文件名

测试:

[root@localhost tpcc-mysql]# ./tpcc_start -h127.0.0.1 -P3306 -d sampson -u root -p mysql -w 10 -c 10 -r 120 -l 120

注意:真实测试场景中,建议预热时间不小于5分钟,持续压测时长不小于30分钟,否则测试数据可能不具参考意义。

测试结果:

[root@localhost tpcc-mysql]# ./tpcc_start -h127.0.0.1 -P3306 -d sampson -u root -p mysql -w 10 -c 10 -r 120 -l 120

***************************************

*** ###easy### TPC-C Load Generator ***

***************************************

option h with value '127.0.0.1'

option P with value '3306'

option d with value 'sampson'

option u with value 'root'

option p with value 'mysql'

option w with value '10'

option c with value '10'

option r with value '120'

option l with value '120'

[server]: 127.0.0.1 ------------主机

[port]: 3306 ------------------端口

[DBname]: sampson ----------压测的数据库

[user]: root ------------------账户

[pass]: mysql ----------------密码

[warehouse]: 10 ----------------仓库数

[connection]: 10 ----------------并发线程数

[rampup]: 120 (sec.) ----------数据预热时长

[measure]: 120 (sec.) ----------压测时长

RAMP-UP TIME.(120 sec.) --------数据预热结束

MEASURING START. --------------开始压测

10, 10(10):19.999|23.476, 8(0):5.040|12.594, 1(0):1.374|1.687, 1(0):19.999|34.468, 0(0):19.999|56.519

20, 9(8):11.255|11.752, 9(1):2.604|5.080, 0(0):0.000|0.000, 1(0):0.000|11.458, 2(2):19.999|58.247

30, 10(9):13.610|15.632, 11(1):2.627|5.563, 1(0):0.000|0.974, 2(0):11.373|21.282, 1(1):0.000|46.330

40, 22(18):16.505|17.051, 20(0):2.034|2.543, 3(0):0.914|2.382, 1(0):0.000|12.158, 2(2):19.999|43.855

50, 20(18):12.967|13.553, 26(0):2.039|2.051, 1(0):0.000|2.282, 2(0):13.067|20.482, 2(2):19.999|54.839

60, 13(11):10.302|11.644, 8(1):2.321|8.205, 2(0):0.705|1.080, 2(0):12.482|17.487, 1(1):0.000|42.983

70, 11(9):8.816|9.680, 13(0):2.056|2.755, 2(0):0.515|0.893, 1(0):0.000|9.504, 2(2):19.999|53.664

80, 9(8):10.421|20.137, 10(0):2.355|2.461, 0(0):0.000|0.000, 1(0):0.000|16.139, 1(1):0.000|43.634

90, 3(3):6.339|18.041, 1(0):0.000|1.422, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000

100, 1(1):0.000|9.972, 2(0):1.477|3.576, 1(0):0.000|0.976, 0(0):0.000|0.000, 0(0):0.000|0.000

110, 16(15):13.330|16.044, 12(0):2.009|2.072, 1(0):0.000|0.910, 1(0):0.000|16.424, 1(1):0.000|45.823

120, 8(8):18.334|18.672, 9(0):2.260|2.551, 1(0):0.000|0.971, 1(0):0.000|17.712, 1(1):0.000|44.961

-------------------------------------------每10秒输出一次压测数据,压测时长120s,共输出12次

-- 以逗号分隔,共6列

-- 第一列,第N次10秒

-- 第二列,新订单成功执行压测的次数(推迟执行压测的次数):90%事务的响应时间|本轮测试最大响应时间,新订单事务数也被                    认为是总有效事务数的指标

-- 第三列,支付业务成功执行次数(推迟执行次数):90%事务的响应时间|本轮测试最大响应时间

-- 第四列,订单状态业务的结果,后面几个的意义同上

-- 第五列,物流发货业务的结果,后面几个的意义同上

-- 第六列,库存仓储业务的结果,后面几个的意义同上

STOPPING THREADS.......... -----------------结束压测

------------------------第一次统计结果

[0] sc:14  lt:118  rt:0  fl:0-------------New-Order,新订单业务成功(success,简写sc)次数,延迟(late,简写lt)次数,重试(retry,简写rt)次数,失败(failure,简写fl)次数

[1] sc:126  lt:3  rt:0  fl:0--------------Payment,支付业务统计,其他同上

[2] sc:13  lt:0  rt:0  fl:0---------------Order-Status,订单状态业务统计,其他同上

[3] sc:13  lt:0  rt:0  fl:0---------------Delivery,发货业务统计,其他同上

[4] sc:0  lt:13  rt:0  fl:0---------------Stock-Level,库存业务统计,其他同上

in 120 sec.

-------------第二次统计结果,其他同上

[0] sc:14  lt:118  rt:0  fl:0

[1] sc:126  lt:3  rt:0  fl:0

[2] sc:13  lt:0  rt:0  fl:0

[3] sc:13  lt:0  rt:0  fl:0

[4] sc:0  lt:13  rt:0  fl:0

(all must be [OK])-----下面所有业务逻辑结果都必须为 OK 才行

[transaction percentage]

Payment: 43.00% (>=43.0%) [OK]----支付成功次数(上述统计结果中sc+lt)必须大于43.0%,否则结果为NG,而不是OK

Order-Status: 4.33% (>= 4.0%) [OK]-----订单状态,其他同上

Delivery: 4.33% (>= 4.0%) [OK]--------发货,其他同上

Stock-Level: 4.33% (>= 4.0%) [OK]------库存,其他同上

[response time (at least 90% passed)]------响应耗时指标必须超过90%通过才行

New-Order: 10.61%  [NG] *

Payment: 97.67%  [OK]

Order-Status: 100.00%  [OK]

Delivery: 100.00%  [OK]

Stock-Level: 0.00%  [NG] *

66.000 TpmC-----TpmC结果值(每分钟事务数,该值是第一次统计结果中的新订单事务数除以总耗时分钟数,例如本例中是:(14+118)/2=66,这里的2是压测时长以分钟计算)

一直调整仓库数,直到为1,所有业务逻辑结果才全是OK,且响应耗时指标都超过了90%。ps:我的虚拟机配置这么低!

[root@localhost tpcc-mysql]# ./tpcc_start -h127.0.0.1 -P3306 -d sampson -u root -p mysql -w 1 -c 10 -r 120 -l 120

***************************************

*** ###easy### TPC-C Load Generator ***

***************************************

option h with value '127.0.0.1'

option P with value '3306'

option d with value 'sampson'

option u with value 'root'

option p with value 'mysql'

option w with value '1'

option c with value '10'

option r with value '120'

option l with value '120'

[server]: 127.0.0.1

[port]: 3306

[DBname]: sampson

[user]: root

[pass]: mysql

[warehouse]: 1

[connection]: 10

[rampup]: 120 (sec.)

[measure]: 120 (sec.)

RAMP-UP TIME.(120 sec.)

MEASURING START.

10, 525(7):10.151|29.286, 519(0):1.854|9.238, 52(0):1.610|2.454, 53(0):8.033|11.347, 52(1):19.999|47.850

20, 489(1):3.995|11.156, 489(1):1.112|7.692, 50(0):0.690|0.772, 48(0):6.352|8.513, 49(0):13.274|14.293

30, 606(3):4.290|9.320, 611(1):1.271|7.210, 59(0):1.659|1.685, 61(0):5.299|6.165, 61(0):10.935|13.769

40, 492(4):4.562|9.583, 488(1):1.748|5.786, 50(0):0.396|0.444, 50(0):5.250|7.533, 49(0):11.144|11.757

50, 575(4):3.780|27.336, 578(2):1.417|23.727, 58(0):0.430|0.798, 57(0):4.310|5.379, 57(0):14.092|15.045

60, 568(7):5.220|11.017, 565(0):1.123|2.107, 57(0):1.118|4.742, 56(0):5.586|11.142, 58(0):10.124|13.559

70, 518(4):4.312|6.638, 522(0):1.344|4.206, 52(0):0.598|0.609, 53(0):4.561|4.970, 51(0):11.794|14.335

80, 558(5):4.546|9.356, 555(0):1.464|3.881, 55(0):0.713|2.523, 55(0):5.725|6.693, 55(0):12.486|12.853

90, 535(4):4.459|12.942, 539(0):1.275|3.080, 53(0):0.412|0.767, 54(0):4.278|4.371, 54(0):11.763|16.768

100, 511(4):4.627|6.937, 506(1):1.819|5.054, 51(0):0.597|1.654, 51(0):5.292|5.877, 52(1):19.219|20.809

110, 380(8):5.978|10.211, 384(0):2.146|4.821, 39(0):0.606|0.861, 38(0):6.016|10.186, 37(0):17.525|18.237

120, 566(1):3.784|8.728, 567(0):0.860|1.590, 57(0):0.343|0.421, 56(0):4.350|4.560, 56(1):13.137|20.078

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

[0] sc:6271  lt:52  rt:0  fl:0

[1] sc:6317  lt:6  rt:0  fl:0

[2] sc:633  lt:0  rt:0  fl:0

[3] sc:632  lt:0  rt:0  fl:0

[4] sc:628  lt:3  rt:0  fl:0

in 120 sec.

[0] sc:6274  lt:52  rt:0  fl:0

[1] sc:6317  lt:6  rt:0  fl:0

[2] sc:633  lt:0  rt:0  fl:0

[3] sc:632  lt:0  rt:0  fl:0

[4] sc:628  lt:3  rt:0  fl:0

(all must be [OK])

[transaction percentage]

Payment: 43.48% (>=43.0%) [OK]

Order-Status: 4.35% (>= 4.0%) [OK]

Delivery: 4.35% (>= 4.0%) [OK]

Stock-Level: 4.34% (>= 4.0%) [OK]

[response time (at least 90% passed)]

New-Order: 99.18%  [OK]

Payment: 99.91%  [OK]

Order-Status: 100.00%  [OK]

Delivery: 100.00%  [OK]

Stock-Level: 99.52%  [OK]

3161.500 TpmC ----------------6271+52=6323;6323/2=3161.5

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值