MySQL:TPCC性能测试

简介

TPC-C是专门针对联机交易处理系统(OLTP系统)的规范。
tpcc-mysql是percona基于TPC-C(下面简写成TPCC)衍生出来的产品,专用于MySQL基准测试。
github:https://github.com/Percona-Lab/tpcc-mysql

使用

1、安装

$ git clone https://github.com/Percona-Lab/tpcc-mysql
$ cd tpcc-mysql/src
$ make -j2
$ cd ..
$ ls -l
-rwxr-xr-x 1 ocean ocean 102816 Feb 24 19:45 tpcc_load  --提供初始化数据的功能
-rwxr-xr-x 1 ocean ocean 252504 Feb 24 19:45 tpcc_start --进行压力测试

2、创建测试用的库和表

$ mysqladmin -uroot -p123456 create tpcc  
$ mysqlshow -uroot -p                   -- 查看所有表
$ mysql -uroot -p123456 -f tpcc < create_table.sql # 创建测试用的表
$ mysql -uroot -p123456 tpcc < add_fkey_idx.sql # 创建FK和索引
$ mysqlshow -uroot -p123456 tpcc -v -v
mysqlshow: [Warning] Using a password on the command line interface can be insecure.
Database: tpcc
+------------+----------+------------+
|   Tables   | Columns  | Total Rows |
+------------+----------+------------+
| customer   |       21 |          0 |
| district   |       11 |          0 |
| history    |        8 |          0 |
| item       |        5 |          0 |
| new_orders |        3 |          0 |
| order_line |       10 |          0 |
| orders     |        8 |          0 |
| stock      |       17 |          0 |
| warehouse  |        9 |          0 |
+------------+----------+------------+
9 rows in set.

3、导入数据

$ sudo ./tpcc_load --help
*************************************
*** TPCC-mysql Data Loader        ***
*************************************
./tpcc_load: invalid option -- '-'
Usage: tpcc_load -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -l part -m min_wh -n max_wh
* [part]: 1=ITEMS 2=WAREHOUSE 3=CUSTOMER 4=ORDERS
选项 warehouse 意为指定测试库下的仓库数量
真实测试场景中,仓库数一般不建议少于100个,视服务器硬件配置而定,如果是配备了SSD或者PCIE SSD这种高IOPS设备的话,建议最少不低于1000个。
$ ./tpcc_load -h 127.0.0.1 -P 3306 -d tpcc -u root -p 123456 -w 1
$  mysqlshow -uroot -p123456 tpcc -v -v
mysqlshow: [Warning] Using a password on the command line interface can be insecure.
Database: tpcc
+------------+----------+------------+
|   Tables   | Columns  | Total Rows |
+------------+----------+------------+
| customer   |       21 |      30000 |
| district   |       11 |         10 |
| history    |        8 |      30000 |
| item       |        5 |     100000 |
| new_orders |        3 |       9000 |
| order_line |       10 |     299907 |
| orders     |        8 |      30000 |
| stock      |       17 |     100000 |
| warehouse  |        9 |          1 |
+------------+----------+------------+

4、开始测试

$ ./tpcc_start --help 
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
$  ./tpcc_start -h 127.0.0.1 -P 3306 -d tpcc -u root -p 123456 -w 1 -c 2 -r -l 30 -i 3 -f tpcc_mysql.log  --每隔3s打印一次
# -w warehouse -c connections -r warmup_time -I running_time -i report-interval -f report-file


option P with value '3358'  #运行tpcc_start时,带的参数
---
<Parameters>  #实际使用的参数
****
  [warehouse]: 10   #仓库数量
 [connection]: 30   #并发连接数
     [rampup]: 120 (sec.)  #预热时间,将数据写入到buffer_pool中
    [measure]: 120 (sec.)  #压测时长
RAMP-UP TIME.(120 sec.)  #预热结束

MEASURING START.  #压测开始

   3, trx: 70, 95%: 66.988, 99%: 329.113, max_rt: 584.639, 68|301.695, 7|84.776, 6|1039.259, 7|29.992
   6, trx: 59, 95%: 95.539, 99%: 246.101, max_rt: 577.888, 61|556.835, 6|53.566, 6|332.305, 6|36.142
每3s打印一次


<Raw Results>  --第一次统计结果
  [0] sc:0 lt:465  rt:0  fl:0 avg_rt: 30.0 (5)
        --新建订单 success成功9749,later操作延时0,retry重试0, failure操作失败0
  [1] sc:17 lt:445  rt:0  fl:0 
        --支付,成功17,延时445,重试0,失败0,
  [2] sc:974  lt:1  rt:0  fl:0 
        --查询订单,同上
  [3] sc:975  lt:0  rt:0  fl:0 
        --发货
  [4] sc:978  lt:0  rt:0  fl:0 
        --查询库存,同上
 in 18 sec.
 
<Raw Results2(sum ver.)> --第二次统计结果
  [0] sc:9749  lt:8  rt:0  fl:0
  [1] sc:9758  lt:2  rt:0  fl:0
  [2] sc:974  lt:1  rt:0  fl:0
  [3] sc:975  lt:0  rt:0  fl:0
  [4] sc:978  lt:0  rt:0  fl:0
 
<Constraint Check> (all must be [OK]) --测试结果的要求
 [transaction percentage]  --事物比例
        Payment: 43.48% (>=43.0%) [OK]  --支付,43.48%,(参考考标准>=43.0%) OK
   Order-Status: 4.34% (>= 4.0%) [OK]   --订单状态
       Delivery: 4.34% (>= 4.0%) [OK]   --发货
    Stock-Level: 4.36% (>= 4.0%) [OK]    --查库存
 [response time (at least 90% passed)]    --响应时间,必须超过90%才算通过
      New-Order: 99.92%  [OK]    --创建订单
        Payment: 99.98%  [OK]    --支付
   Order-Status: 99.90%  [OK]    --查询状态
       Delivery: 100.00%  [OK]    --发货

<TpmC>                    #每分钟的测试事务数
                 1550.000 TpmC

--Tpmc,transactions per minute ,每分钟处理订单个数的能力,需要注意的是,这个参数不仅仅是其他什么不跑,尽在那里处理新订单了,而是同时也会在进行订单查询,查库存等操作;
 tpmC值在国内外被广 泛用于衡量计算机系统的事务处理能力,已经是公众认可的标准

获取QPS

mysqladmin -h127.0.0.1  extended-status -uroot -p123456 -i1 | grep "Question"
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
| Questions                                             | 1465339                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Questions                                             | 1465340    
QPS为146万多

6、绘制图片

直接使用excel将 tpcc_mysql.log里面的数据绘制出来

总结:

  • sysbench更倾向于Mysql性能,TPCC更接近业务。
  • 运行测试程序需要同时监控机器负载,MYSQL各项监控指标
    参考:https://www.cnblogs.com/Aiapple/p/5705146.html
    参考:https://blog.csdn.net/laiyijian/article/details/70332409
    https://blog.csdn.net/jswangchang/article/details/81317741
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值