当前位置:   article > 正文

【压测初体验】sysbench压测MySQL数据库_sysbench oltp_read_only

sysbench oltp_read_only

目录

压测前准备

测试表准备

压测结果分析

开始压测

    综合TPS(oltp_read_write模式)

    只读性能(oltp_read_only模式 )

    删除性能(oltp_delete模式 )

    更新索引字段性能(oltp_update_index模式 )

    更新非索引字段性能(oltp_update_non_index模式 )

    插入性能(oltp_insert模式 )

    写入性能(oltp_write_only模式 )

压测结束 - cleanup

压测数据汇总


压测前准备

    机器配置:

  1. # 我用的是虚拟机安装的MySQL,怎么玩看自己
  2. 4vCPUs | 8GB | CentOS 7.3 64bit

    MySQL数据库版本:

5.7.32

    创建测试库:

  1. create database test_db character set
  2. utf8mb4 collate utf8mb4_bin;

    sysbench工具安装:

  1. curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash
  2. sudo yum -y install sysbench
  3. sysbench --version

    上面指令执行完之后,可以看到安装的sysbench工具版本:

sysbench 1.0.19 

测试表准备

    可以通过下面这条指令,基于sysbench指令构造测试表和测试数据:

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test_user --mysql-password=12345678 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable prepare

    参数分析

  1. # 基于mysql的驱动去连接mysql数据库,如果是oracle、SQLserver就是用对应的数据库驱动
  2. --db-driver=mysql
  3. # 连续访问300秒
  4. --time=300
  5. # 10个线程模拟并发访问
  6. --threads=10
  7. # 每隔1秒输出一下压测情况
  8. --report-interval=1
  9. # 数据库所在机器的IP地址
  10. --mysql-host=127.0.0.1
  11. # 端口号:3306
  12. --mysql-port=3306
  13. # 用户名
  14. --mysql-user=test_user
  15. # 密码
  16. --mysql-password=12345678
  17. # 压测数据库
  18. --mysql-db=test_db
  19. # 模拟构造20个测试表
  20. --tables=20
  21. # 每个表构造100万条测试数据,测试表的名字会是类似于sbtest1,sbtest2这样
  22. --table_size=1000000
  23. # 执行oltp数据库的读写测试
  24. oltp_read_write
  25. # 禁止ps模式
  26. --db-ps-mode=disable
  27. # 参照这个命令的设置去构造出来我们需要的数据库里的数据
  28. # 自动创建20个测试表,每个表里创建100万条测试数据
  29. prepare

    执行命令之后,界面输出:

  1. Initializing worker threads...
  2. Creating table 'sbtest7'...
  3. Creating table 'sbtest9'...
  4. Creating table 'sbtest5'...
  5. Creating table 'sbtest8'...
  6. Creating table 'sbtest3'...
  7. Creating table 'sbtest4'...
  8. Creating table 'sbtest1'...
  9. Creating table 'sbtest6'...
  10. Creating table 'sbtest2'...
  11. Creating table 'sbtest10'...
  12. Inserting 1000000 records into 'sbtest1'
  13. Inserting 1000000 records into 'sbtest5'
  14. Inserting 1000000 records into 'sbtest3'
  15. Inserting 1000000 records into 'sbtest8'
  16. Inserting 1000000 records into 'sbtest4'
  17. Inserting 1000000 records into 'sbtest7'
  18. Inserting 1000000 records into 'sbtest9'
  19. Inserting 1000000 records into 'sbtest2'
  20. Inserting 1000000 records into 'sbtest6'
  21. Inserting 1000000 records into 'sbtest10'

    待测试表和测试数据构造完毕之后就可以开始进行压测了~

压测结果分析

    每秒输出的压测报告如下:

  1. # 测试命令执行过程中,每秒会输出类似下面这段内容的压测报告
  2. [ 300s ] thds: 10 tps: 8.07 qps: 177.56 (r/w/o: 121.06/40.35/16.14) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00

    (每秒输出)压测报告分析:

  1. # 第300秒输出的压测报告
  2. [ 300s ]
  3. # 压测线程数量:10个
  4. thds: 10
  5. # 每秒执行事务数量:8.07个
  6. tps: 8.07
  7. # 每秒执行请求数量:177.56个
  8. qps: 177.56
  9. # 每秒的请求数中,读请求个数/写请求个数/其他请求个数
  10. # 每秒(177.56个)请求中,读请求:121.06个、写请求:40.35个,其他请求:16.14个
  11. (r/w/o: 121.06/40.35/16.14)
  12. # 95%的请求延迟在1327.91ms以下
  13. lat (ms,95%): 1327.91
  14. # 每秒请求数中的失败数量
  15. err/s: 0.00
  16. # 每秒请求数中的重连数量
  17. reconn/s: 0.00

    压测完成之后,会显示一个总压测报告,内容及分析如下:

  1. SQL statistics:
  2. queries performed:
  3. read: 51814 # 在300s的压测时间内执行了5万多次读请求
  4. write: 14804 # 压测时间内执行了1万多次写请求
  5. other: 7402 # 压测时间内执行了7千多次其他请求
  6. total: 74020 # 压测时间内一共执行了7万多请求
  7. transactions: 3701 (12.32 per sec.) # 压测时间内一共执行了3701个事务,每秒执行12.32个事务
  8. queries: 74020 (246.35 per sec.) # 压测时间内一共执行了7.4万多次请求,每秒执行246.35次请求
  9. ignored errors: 0 (0.00 per sec.)
  10. reconnects: 0 (0.00 per sec.)
  11. # 一共执行了300s的压测,执行了3701个事务
  12. General statistics:
  13. total time: 300.4640s
  14. total number of events: 3701
  15. Latency (ms):
  16. min: 2.96 # 请求中延迟最小的是2.96ms
  17. avg: 811.65 # 所有请求的平均延迟是811.65ms
  18. max: 4516.35 # 请求中延迟最大的是4516.35ms
  19. 95th percentile: 1869.60 # 95%的请求延迟在1869.60ms以内
  20. sum: 3003916.38
  21. Threads fairness:
  22. events (avg/stddev): 370.1000/9.20
  23. execution time (avg/stddev): 300.3916/0.14

开始压测

    综合TPS(oltp_read_write模式)

        测试命令:

  1. # 命令最后不是prepare,是run了,意思就是运行压测
  2. sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=12345678 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable run

        压测过程中,每秒输出的压测报告:

  1. # 这里只是截取出来的部分输出内容
  2. Running the test with following options:
  3. Number of threads: 10
  4. Report intermediate results every 1 second(s)
  5. Initializing random number generator from current time
  6. Initializing worker threads...
  7. Threads started!
  8. [ 1s ] thds: 10 tps: 0.99 qps: 199.95 (r/w/o: 153.19/34.82/11.94) lat (ms,95%): 694.45 err/s: 0.00 reconn/s: 0.00
  9. [ 2s ] thds: 10 tps: 10.03 qps: 182.64 (r/w/o: 136.48/26.09/20.07) lat (ms,95%): 1618.78 err/s: 0.00 reconn/s: 0.00
  10. [ 3s ] thds: 10 tps: 7.99 qps: 133.76 (r/w/o: 91.83/25.95/15.97) lat (ms,95%): 1869.60 err/s: 0.00 reconn/s: 0.00
  11. [ 4s ] thds: 10 tps: 8.01 qps: 180.28 (r/w/o: 124.20/40.06/16.03) lat (ms,95%): 1836.24 err/s: 0.00 reconn/s: 0.00
  12. [ 5s ] thds: 10 tps: 11.01 qps: 201.10 (r/w/o: 145.07/34.02/22.01) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
  13. [ 6s ] thds: 10 tps: 10.00 qps: 212.92 (r/w/o: 144.95/47.98/19.99) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
  14. [ 7s ] thds: 10 tps: 4.99 qps: 78.79 (r/w/o: 51.86/16.95/9.97) lat (ms,95%): 1506.29 err/s: 0.00 reconn/s: 0.00
  15. ......
  16. [ 294s ] thds: 10 tps: 0.00 qps: 150.40 (r/w/o: 116.76/33.64/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
  17. [ 295s ] thds: 10 tps: 9.03 qps: 174.56 (r/w/o: 122.39/34.11/18.06) lat (ms,95%): 1973.38 err/s: 0.00 reconn/s: 0.00
  18. [ 296s ] thds: 10 tps: 15.32 qps: 302.29 (r/w/o: 217.52/54.13/30.64) lat (ms,95%): 1149.76 err/s: 0.00 reconn/s: 0.00
  19. [ 297s ] thds: 10 tps: 20.01 qps: 381.15 (r/w/o: 262.10/79.03/40.02) lat (ms,95%): 1191.92 err/s: 0.00 reconn/s: 0.00
  20. [ 298s ] thds: 10 tps: 14.01 qps: 214.12 (r/w/o: 146.08/40.02/28.02) lat (ms,95%): 773.68 err/s: 0.00 reconn/s: 0.00
  21. [ 299s ] thds: 10 tps: 17.85 qps: 315.32 (r/w/o: 216.17/63.46/35.70) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
  22. [ 300s ] thds: 10 tps: 8.07 qps: 177.56 (r/w/o: 121.06/40.35/16.14) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00

        测试结果:

  1. SQL statistics:
  2. queries performed:
  3. read: 51814
  4. write: 14804
  5. other: 7402
  6. total: 74020
  7. transactions: 3701 (12.32 per sec.)
  8. queries: 74020 (246.35 per sec.)
  9. ignored errors: 0 (0.00 per sec.)
  10. reconnects: 0 (0.00 per sec.)
  11. General statistics:
  12. total time: 300.4640s
  13. total number of events: 3701
  14. Latency (ms):
  15. min: 2.96
  16. avg: 811.65
  17. max: 4516.35
  18. 95th percentile: 1869.60
  19. sum: 3003916.38
  20. Threads fairness:
  21. events (avg/stddev): 370.1000/9.20
  22. execution time (avg/stddev): 300.3916/0.14

    只读性能(oltp_read_only模式 )

        测试命令:

  1. # 命令中的oltp_read_write已经变为oltp_read_only了
  2. sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=12345678 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_only --db-ps-mode=disable run

        压测过程中,每秒输出的压测报告:

  1. sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
  2. Running the test with following options:
  3. Number of threads: 10
  4. Report intermediate results every 1 second(s)
  5. Initializing random number generator from current time
  6. Initializing worker threads...
  7. Threads started!
  8. [ 1s ] thds: 10 tps: 150.79 qps: 2499.46 (r/w/o: 2187.90/0.00/311.56) lat (ms,95%): 277.21 err/s: 0.00 reconn/s: 0.00
  9. [ 2s ] thds: 10 tps: 158.02 qps: 2534.27 (r/w/o: 2218.24/0.00/316.03) lat (ms,95%): 277.21 err/s: 0.00 reconn/s: 0.00
  10. [ 3s ] thds: 10 tps: 198.44 qps: 3149.12 (r/w/o: 2752.24/0.00/396.88) lat (ms,95%): 189.93 err/s: 0.00 reconn/s: 0.00
  11. [ 4s ] thds: 10 tps: 178.50 qps: 2867.05 (r/w/o: 2510.05/0.00/357.00) lat (ms,95%): 231.53 err/s: 0.00 reconn/s: 0.00
  12. [ 5s ] thds: 10 tps: 174.87 qps: 2814.85 (r/w/o: 2465.11/0.00/349.73) lat (ms,95%): 158.63 err/s: 0.00 reconn/s: 0.00
  13. [ 6s ] thds: 10 tps: 223.15 qps: 3548.41 (r/w/o: 3102.11/0.00/446.30) lat (ms,95%): 207.82 err/s: 0.00 reconn/s: 0.00
  14. [ 7s ] thds: 10 tps: 189.02 qps: 3064.34 (r/w/o: 2686.29/0.00/378.04) lat (ms,95%): 248.83 err/s: 0.00 reconn/s: 0.00
  15. [ 8s ] thds: 10 tps: 184.90 qps: 2951.38 (r/w/o: 2581.58/0.00/369.80) lat (ms,95%): 227.40 err/s: 0.00 reconn/s: 0.00
  16. ......
  17. [ 295s ] thds: 10 tps: 3381.18 qps: 54086.89 (r/w/o: 47324.53/0.00/6762.36) lat (ms,95%): 3.82 err/s: 0.00 reconn/s: 0.00
  18. [ 296s ] thds: 10 tps: 3318.25 qps: 53097.96 (r/w/o: 46461.47/0.00/6636.49) lat (ms,95%): 3.96 err/s: 0.00 reconn/s: 0.00
  19. [ 297s ] thds: 10 tps: 3346.59 qps: 53547.42 (r/w/o: 46854.25/0.00/6693.18) lat (ms,95%): 3.89 err/s: 0.00 reconn/s: 0.00
  20. [ 298s ] thds: 10 tps: 3346.55 qps: 53562.78 (r/w/o: 46869.68/0.00/6693.10) lat (ms,95%): 4.65 err/s: 0.00 reconn/s: 0.00
  21. [ 299s ] thds: 10 tps: 3366.59 qps: 53847.43 (r/w/o: 47115.25/0.00/6732.18) lat (ms,95%): 3.89 err/s: 0.00 reconn/s: 0.00
  22. [ 300s ] thds: 10 tps: 3347.53 qps: 53570.47 (r/w/o: 46875.41/0.00/6695.06) lat (ms,95%): 3.96 err/s: 0.00 reconn/s: 0.00

        测试结果:

  1. SQL statistics:
  2. queries performed:
  3. read: 11724524
  4. write: 0
  5. other: 1674932
  6. total: 13399456
  7. transactions: 837466 (2791.50 per sec.)
  8. queries: 13399456 (44664.05 per sec.)
  9. ignored errors: 0 (0.00 per sec.)
  10. reconnects: 0 (0.00 per sec.)
  11. General statistics:
  12. total time: 300.0043s
  13. total number of events: 837466
  14. Latency (ms):
  15. min: 1.00
  16. avg: 3.58
  17. max: 1146.30
  18. 95th percentile: 4.03
  19. sum: 2998671.04
  20. Threads fairness:
  21. events (avg/stddev): 83746.6000/776.59
  22. execution time (avg/stddev): 299.8671/0.01

    删除性能(oltp_delete模式 )

        测试命令:

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=12345678 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_delete --db-ps-mode=disable run

        压测过程中每秒输出压测报告:

  1. sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
  2. Running the test with following options:
  3. Number of threads: 10
  4. Report intermediate results every 1 second(s)
  5. Initializing random number generator from current time
  6. Initializing worker threads...
  7. Threads started!
  8. [ 1s ] thds: 10 tps: 420.52 qps: 420.52 (r/w/o: 0.00/420.52/0.00) lat (ms,95%): 74.46 err/s: 0.00 reconn/s: 0.00
  9. [ 2s ] thds: 10 tps: 122.08 qps: 122.08 (r/w/o: 0.00/122.08/0.00) lat (ms,95%): 204.11 err/s: 0.00 reconn/s: 0.00
  10. [ 3s ] thds: 10 tps: 49.18 qps: 49.18 (r/w/o: 0.00/49.18/0.00) lat (ms,95%): 909.80 err/s: 0.00 reconn/s: 0.00
  11. [ 4s ] thds: 10 tps: 270.18 qps: 270.18 (r/w/o: 0.00/268.18/2.00) lat (ms,95%): 99.33 err/s: 0.00 reconn/s: 0.00
  12. ......
  13. [ 294s ] thds: 10 tps: 156.95 qps: 156.95 (r/w/o: 0.00/145.25/11.70) lat (ms,95%): 475.79 err/s: 0.00 reconn/s: 0.00
  14. [ 295s ] thds: 10 tps: 35.91 qps: 35.91 (r/w/o: 0.00/34.88/1.03) lat (ms,95%): 877.61 err/s: 0.00 reconn/s: 0.00
  15. [ 296s ] thds: 10 tps: 27.07 qps: 27.07 (r/w/o: 0.00/24.06/3.01) lat (ms,95%): 682.06 err/s: 0.00 reconn/s: 0.00
  16. [ 297s ] thds: 10 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
  17. [ 298s ] thds: 10 tps: 140.00 qps: 140.00 (r/w/o: 0.00/129.00/11.00) lat (ms,95%): 1109.09 err/s: 0.00 reconn/s: 0.00
  18. [ 299s ] thds: 10 tps: 184.75 qps: 184.75 (r/w/o: 0.00/172.83/11.92) lat (ms,95%): 102.97 err/s: 0.00 reconn/s: 0.00
  19. [ 300s ] thds: 10 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00

        压测结果:

  1. SQL statistics:
  2. queries performed:
  3. read: 0
  4. write: 21303
  5. other: 900
  6. total: 22203
  7. transactions: 22203 (73.88 per sec.)
  8. queries: 22203 (73.88 per sec.)
  9. ignored errors: 0 (0.00 per sec.)
  10. reconnects: 0 (0.00 per sec.)
  11. General statistics:
  12. total time: 300.5215s
  13. total number of events: 22203
  14. Latency (ms):
  15. min: 0.05
  16. avg: 135.35
  17. max: 2596.49
  18. 95th percentile: 846.57
  19. sum: 3005165.33
  20. Threads fairness:
  21. events (avg/stddev): 2220.3000/16.70
  22. execution time (avg/stddev): 300.5165/0.00

    更新索引字段性能(oltp_update_index模式 )

        测试命令:

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=12345678 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_update_index --db-ps-mode=disable run

        压测过程中每秒输出压测报告:

  1. sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
  2. Running the test with following options:
  3. Number of threads: 10
  4. Report intermediate results every 1 second(s)
  5. Initializing random number generator from current time
  6. Initializing worker threads...
  7. Threads started!
  8. [ 1s ] thds: 10 tps: 270.62 qps: 270.62 (r/w/o: 0.00/254.88/15.75) lat (ms,95%): 101.13 err/s: 0.00 reconn/s: 0.00
  9. [ 2s ] thds: 10 tps: 232.49 qps: 232.49 (r/w/o: 0.00/212.36/20.13) lat (ms,95%): 101.13 err/s: 0.00 reconn/s: 0.00
  10. [ 3s ] thds: 10 tps: 151.27 qps: 151.27 (r/w/o: 0.00/142.20/9.08) lat (ms,95%): 746.32 err/s: 0.00 reconn/s: 0.00
  11. [ 4s ] thds: 10 tps: 271.84 qps: 271.84 (r/w/o: 0.00/251.85/19.99) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
  12. [ 5s ] thds: 10 tps: 5.75 qps: 5.75 (r/w/o: 0.00/5.75/0.00) lat (ms,95%): 1258.08 err/s: 0.00 reconn/s: 0.00
  13. [ 6s ] thds: 10 tps: 186.05 qps: 186.05 (r/w/o: 0.00/168.28/17.77) lat (ms,95%): 434.83 err/s: 0.00 reconn/s: 0.00
  14. ......
  15. [ 295s ] thds: 10 tps: 21.01 qps: 21.01 (r/w/o: 0.00/20.01/1.00) lat (ms,95%): 1191.92 err/s: 0.00 reconn/s: 0.00
  16. [ 296s ] thds: 10 tps: 208.03 qps: 208.03 (r/w/o: 0.00/189.02/19.00) lat (ms,95%): 179.94 err/s: 0.00 reconn/s: 0.00
  17. [ 297s ] thds: 10 tps: 14.91 qps: 14.91 (r/w/o: 0.00/12.92/1.99) lat (ms,95%): 1050.76 err/s: 0.00 reconn/s: 0.00
  18. [ 298s ] thds: 10 tps: 12.05 qps: 12.05 (r/w/o: 0.00/10.04/2.01) lat (ms,95%): 502.20 err/s: 0.00 reconn/s: 0.00
  19. [ 299s ] thds: 10 tps: 22.54 qps: 22.54 (r/w/o: 0.00/21.56/0.98) lat (ms,95%): 1170.65 err/s: 0.00 reconn/s: 0.00
  20. [ 300s ] thds: 10 tps: 12.27 qps: 12.27 (r/w/o: 0.00/11.25/1.02) lat (ms,95%): 1213.57 err/s: 0.00 reconn/s: 0.00

        压测结果:

  1. SQL statistics:
  2. queries performed:
  3. read: 0
  4. write: 12396
  5. other: 1064
  6. total: 13460
  7. transactions: 13460 (44.76 per sec.)
  8. queries: 13460 (44.76 per sec.)
  9. ignored errors: 0 (0.00 per sec.)
  10. reconnects: 0 (0.00 per sec.)
  11. General statistics:
  12. total time: 300.6863s
  13. total number of events: 13460
  14. Latency (ms):
  15. min: 0.06
  16. avg: 223.11
  17. max: 2541.52
  18. 95th percentile: 1013.60
  19. sum: 3003113.54
  20. Threads fairness:
  21. events (avg/stddev): 1346.0000/13.31
  22. execution time (avg/stddev): 300.3114/0.19

    更新非索引字段性能(oltp_update_non_index模式 )

        测试命令:

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=12345678 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_update_non_index --db-ps-mode=disable run

        压测过程中每秒输出压测报告:

  1. sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
  2. Running the test with following options:
  3. Number of threads: 10
  4. Report intermediate results every 1 second(s)
  5. Initializing random number generator from current time
  6. Initializing worker threads...
  7. Threads started!
  8. [ 1s ] thds: 10 tps: 470.88 qps: 470.88 (r/w/o: 0.00/430.07/40.82) lat (ms,95%): 74.46 err/s: 0.00 reconn/s: 0.00
  9. [ 2s ] thds: 10 tps: 195.01 qps: 195.01 (r/w/o: 0.00/181.01/14.00) lat (ms,95%): 99.33 err/s: 0.00 reconn/s: 0.00
  10. [ 3s ] thds: 10 tps: 15.97 qps: 15.97 (r/w/o: 0.00/13.98/2.00) lat (ms,95%): 861.95 err/s: 0.00 reconn/s: 0.00
  11. [ 4s ] thds: 10 tps: 101.48 qps: 101.48 (r/w/o: 0.00/91.43/10.05) lat (ms,95%): 1013.60 err/s: 0.00 reconn/s: 0.00
  12. [ 5s ] thds: 10 tps: 147.92 qps: 147.92 (r/w/o: 0.00/136.92/10.99) lat (ms,95%): 36.24 err/s: 0.00 reconn/s: 0.00
  13. ......
  14. [ 295s ] thds: 10 tps: 66.02 qps: 66.02 (r/w/o: 0.00/63.02/3.00) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
  15. [ 296s ] thds: 10 tps: 18.65 qps: 18.65 (r/w/o: 0.00/17.67/0.98) lat (ms,95%): 1258.08 err/s: 0.00 reconn/s: 0.00
  16. [ 297s ] thds: 10 tps: 175.07 qps: 175.07 (r/w/o: 0.00/165.01/10.06) lat (ms,95%): 682.06 err/s: 0.00 reconn/s: 0.00
  17. [ 298s ] thds: 10 tps: 47.43 qps: 47.43 (r/w/o: 0.00/45.45/1.98) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
  18. [ 299s ] thds: 10 tps: 362.57 qps: 362.57 (r/w/o: 0.00/325.69/36.87) lat (ms,95%): 86.00 err/s: 0.00 reconn/s: 0.00
  19. [ 300s ] thds: 10 tps: 26.96 qps: 26.96 (r/w/o: 0.00/26.96/0.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00

        测试结果:

  1. SQL statistics:
  2. queries performed:
  3. read: 0
  4. write: 40517
  5. other: 3565
  6. total: 44082
  7. transactions: 44082 (146.90 per sec.)
  8. queries: 44082 (146.90 per sec.)
  9. ignored errors: 0 (0.00 per sec.)
  10. reconnects: 0 (0.00 per sec.)
  11. General statistics:
  12. total time: 300.0783s
  13. total number of events: 44082
  14. Latency (ms):
  15. min: 0.05
  16. avg: 68.07
  17. max: 2797.30
  18. 95th percentile: 231.53
  19. sum: 3000641.17
  20. Threads fairness:
  21. events (avg/stddev): 4408.2000/28.54
  22. execution time (avg/stddev): 300.0641/0.01

    插入性能(oltp_insert模式 )

        测试命令:

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=12345678 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_insert --db-ps-mode=disable run

        压测过程中每秒输出压测报告:

  1. sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
  2. Running the test with following options:
  3. Number of threads: 10
  4. Report intermediate results every 1 second(s)
  5. Initializing random number generator from current time
  6. Initializing worker threads...
  7. Threads started!
  8. [ 1s ] thds: 10 tps: 259.00 qps: 259.00 (r/w/o: 0.00/259.00/0.00) lat (ms,95%): 99.33 err/s: 0.00 reconn/s: 0.00
  9. [ 2s ] thds: 10 tps: 181.48 qps: 181.48 (r/w/o: 0.00/181.48/0.00) lat (ms,95%): 549.52 err/s: 0.00 reconn/s: 0.00
  10. [ 3s ] thds: 10 tps: 260.01 qps: 260.01 (r/w/o: 0.00/260.01/0.00) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
  11. [ 4s ] thds: 10 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
  12. [ 5s ] thds: 10 tps: 195.74 qps: 195.74 (r/w/o: 0.00/195.74/0.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
  13. ......
  14. [ 295s ] thds: 10 tps: 196.52 qps: 196.52 (r/w/o: 0.00/196.52/0.00) lat (ms,95%): 267.41 err/s: 0.00 reconn/s: 0.00
  15. [ 296s ] thds: 10 tps: 11.75 qps: 11.75 (r/w/o: 0.00/11.75/0.00) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
  16. [ 297s ] thds: 10 tps: 20.44 qps: 20.44 (r/w/o: 0.00/20.44/0.00) lat (ms,95%): 995.51 err/s: 0.00 reconn/s: 0.00
  17. [ 298s ] thds: 10 tps: 297.17 qps: 297.17 (r/w/o: 0.00/297.17/0.00) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
  18. [ 299s ] thds: 10 tps: 74.98 qps: 74.98 (r/w/o: 0.00/74.98/0.00) lat (ms,95%): 314.45 err/s: 0.00 reconn/s: 0.00
  19. [ 300s ] thds: 10 tps: 11.00 qps: 11.00 (r/w/o: 0.00/11.00/0.00) lat (ms,95%): 1213.57 err/s: 0.00 reconn/s: 0.00
  20. [ 301s ] thds: 7 tps: 5.98 qps: 5.98 (r/w/o: 0.00/5.98/0.00) lat (ms,95%): 669.89 err/s: 0.00 reconn/s: 0.00

        压测结果:

  1. SQL statistics:
  2. queries performed:
  3. read: 0
  4. write: 20600
  5. other: 0
  6. total: 20600
  7. transactions: 20600 (68.41 per sec.)
  8. queries: 20600 (68.41 per sec.)
  9. ignored errors: 0 (0.00 per sec.)
  10. reconnects: 0 (0.00 per sec.)
  11. General statistics:
  12. total time: 301.1423s
  13. total number of events: 20600
  14. Latency (ms):
  15. min: 0.48
  16. avg: 146.04
  17. max: 4482.33
  18. 95th percentile: 846.57
  19. sum: 3008453.03
  20. Threads fairness:
  21. events (avg/stddev): 2060.0000/10.58
  22. execution time (avg/stddev): 300.8453/0.24

    写入性能(oltp_write_only模式 )

        测试命令:

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=12345678 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_write_only --db-ps-mode=disable run

        每秒输出压测报告:

  1. sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
  2. Running the test with following options:
  3. Number of threads: 10
  4. Report intermediate results every 1 second(s)
  5. Initializing random number generator from current time
  6. Initializing worker threads...
  7. Threads started!
  8. [ 1s ] thds: 10 tps: 301.69 qps: 1840.14 (r/w/o: 0.00/1145.87/694.27) lat (ms,95%): 66.84 err/s: 0.00 reconn/s: 0.00
  9. [ 2s ] thds: 10 tps: 237.18 qps: 1442.34 (r/w/o: 0.00/898.52/543.82) lat (ms,95%): 164.45 err/s: 0.00 reconn/s: 0.00
  10. [ 3s ] thds: 10 tps: 58.59 qps: 343.44 (r/w/o: 0.00/216.34/127.10) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
  11. [ 4s ] thds: 10 tps: 15.65 qps: 66.77 (r/w/o: 0.00/35.47/31.30) lat (ms,95%): 1352.03 err/s: 0.00 reconn/s: 0.00
  12. ......
  13. [ 295s ] thds: 10 tps: 1.00 qps: 16.00 (r/w/o: 0.00/14.00/2.00) lat (ms,95%): 95.81 err/s: 0.00 reconn/s: 0.00
  14. [ 296s ] thds: 10 tps: 15.10 qps: 77.51 (r/w/o: 0.00/47.31/30.20) lat (ms,95%): 1678.14 err/s: 0.00 reconn/s: 0.00
  15. [ 297s ] thds: 10 tps: 19.27 qps: 115.63 (r/w/o: 0.00/73.23/42.40) lat (ms,95%): 926.33 err/s: 0.00 reconn/s: 0.00
  16. [ 298s ] thds: 10 tps: 20.78 qps: 125.71 (r/w/o: 0.00/79.99/45.71) lat (ms,95%): 1013.60 err/s: 0.00 reconn/s: 0.00
  17. [ 299s ] thds: 10 tps: 20.98 qps: 123.90 (r/w/o: 0.00/76.94/46.96) lat (ms,95%): 707.07 err/s: 0.00 reconn/s: 0.00
  18. [ 300s ] thds: 10 tps: 0.00 qps: 39.98 (r/w/o: 0.00/38.99/1.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00

        压测结果:

  1. SQL statistics:
  2. queries performed:
  3. read: 0
  4. write: 26215
  5. other: 15647
  6. total: 41862
  7. transactions: 6977 (23.24 per sec.)
  8. queries: 41862 (139.43 per sec.)
  9. ignored errors: 0 (0.00 per sec.)
  10. reconnects: 0 (0.00 per sec.)
  11. General statistics:
  12. total time: 300.2274s
  13. total number of events: 6977
  14. Latency (ms):
  15. min: 1.20
  16. avg: 430.30
  17. max: 2321.44
  18. 95th percentile: 1213.57
  19. sum: 3002230.29
  20. Threads fairness:
  21. events (avg/stddev): 697.7000/5.39
  22. execution time (avg/stddev): 300.2230/0.00

压测结束 - cleanup

    清除数据命令:

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=12345678 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable cleanup

压测数据汇总

模式其他总请求事物TPSQPS最小延迟(ms)最大延迟(ms)平均延迟(ms)95%(ms)
oltp_read_write5181414804740274020370112.32246.352.964516.35811.651869.60
oltp_read_only1172452401674932133994568374662791.5044664.051.001146.303.584.03
oltp_delete021303900222032220373.8873.880.052596.49135.35846.57
oltp_update_index0123961064134601346044.7644.760.062541.52223.111013.60
oltp_update_non_index04051735654408244082146.90146.900.052797.3068.07231.53
oltp_insert0206000206002060068.4168.410.484482.33146.04846.57
oltp_write_only0262151564741862697723.24139.431.202321.44430.301213.57

  

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/92323
推荐阅读
相关标签
  

闽ICP备14008679号