MYSQL系列(54):性能测试之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
tpcc_load  提供初始化数据的功能
 tpcc_start 进行压力测试 

创建测试用的库和表

$ 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.
$ 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 |
+------------+----------+------------+
$ ./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打印一次
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
option h with value '127.0.0.1'
option P with value '3306'
option d with value 'tpcc'
option u with value 'root'
option p with value '123456'
option w with value '1'
option c with value '2'
option r with value '-l'
option i with value '3'
option f with value 'tpcc_mysql.log'
non-option ARGV-elements: 30 
<Parameters>
     [server]: 127.0.0.1
     [port]: 3306
     [DBname]: tpcc
       [user]: root
       [pass]: 123456
  [warehouse]: 1
 [connection]: 2
     [rampup]: 0 (sec.)
    [measure]: 20 (sec.)

RAMP-UP TIME.(0 sec.)

MEASURING START.

   3, trx: 91, 95%: 122.448, 99%: 335.579, max_rt: 622.958, 90|239.834, 9|1.326, 8|670.834, 9|37.597
   6, trx: 97, 95%: 136.339, 99%: 275.502, max_rt: 355.741, 98|335.524, 10|1.286, 10|575.857, 10|40.230
   9, trx: 63, 95%: 95.825, 99%: 194.506, max_rt: 440.135, 62|722.038, 6|1.620, 7|851.402, 6|40.528
  12, trx: 54, 95%: 621.911, 99%: 863.912, max_rt: 942.300, 55|111.504, 6|1.665, 5|346.742, 5|36.920
  15, trx: 94, 95%: 37.558, 99%: 367.769, max_rt: 369.549, 94|256.111, 9|1.450, 9|601.735, 10|44.846
  18, trx: 91, 95%: 71.142, 99%: 686.070, max_rt: 687.652, 89|778.037, 9|1.467, 10|902.038, 9|43.130

STOPPING THREADS..

<Raw Results>
  [0] sc:0 lt:490  rt:0  fl:0 avg_rt: 35.0 (5)  --新订单业务成功(success,简写sc)次数,延迟(late,简写lt)次数,重试(retry,简写rt)次数,失败(failure,简写fl)次数
  [1] sc:123 lt:365  rt:0  fl:0 avg_rt: 18.0 (5)
  [2] sc:49 lt:0  rt:0  fl:0 avg_rt: 1.0 (5)
  [3] sc:25 lt:24  rt:0  fl:0 avg_rt: 175.6 (80)
  [4] sc:12 lt:37  rt:0  fl:0 avg_rt: 28.2 (20)
 in 18 sec.
解释:
<Raw Results2(sum ver.)>
  [0] sc:0  lt:490  rt:0  fl:0 
  [1] sc:123  lt:365  rt:0  fl:0 
  [2] sc:49  lt:0  rt:0  fl:0 
  [3] sc:25  lt:24  rt:0  fl:0 
  [4] sc:12  lt:37  rt:0  fl:0 

<Constraint Check> (all must be [OK])
 [transaction percentage]
        Payment: 43.38% (>=43.0%) [OK]
   Order-Status: 4.36% (>= 4.0%) [OK]
       Delivery: 4.36% (>= 4.0%) [OK]
    Stock-Level: 4.36% (>= 4.0%) [OK]
 [response time (at least 90% passed)]
      New-Order: 0.00%  [NG] *
        Payment: 25.20%  [NG] *
   Order-Status: 100.00%  [OK]
       Delivery: 51.02%  [NG] *
    Stock-Level: 24.49%  [NG] *

<TpmC>
                 1633.333 TpmC

参考:https://www.cnblogs.com/Aiapple/p/5705146.html
参考:https://blog.csdn.net/laiyijian/article/details/70332409

https://blog.csdn.net/jswangchang/article/details/81317741 【还没看完】

猜你喜欢

转载自blog.csdn.net/zhizhengguan/article/details/87914702
今日推荐