前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >sb测压工具你知多少?

sb测压工具你知多少?

作者头像
手撕代码八百里
发布2021-04-20 10:15:58
7230
发布2021-04-20 10:15:58
举报
文章被收录于专栏:猿计划

sb测压工具

文章目录

一、简单介绍

首先sb并不是“傻X”的意思。

其实是SuperBenchmarker的缩写,简称SB。

是一个开源的测压工具,挺好用的。

SuperBenchmarker 是ㄧ个开源的类似于Apache ab的压力测试命令行工具。

可支持Get、Post、Put、Delete这些调用方式,调用时能指定Concurrent user、Request数、Header template…等。

二、如何得到sb工具呢?

最有效的方法无非是通过官方通道进行下载了。

可以通过github的地址下载该程序:

github地址:https://github.com/aliostad/SuperBenchmarker

如果你是windows用户的话,

Github用户可在download目录内取得编译好的程序主文件,

可以在download目录中下载sb.exe文件

在这里插入图片描述
在这里插入图片描述

例如:我下载好,就放在了D盘下的soft目录下的utils目录下了:

在这里插入图片描述
在这里插入图片描述

三、如何随心所欲的使用sb工具?

当你打开cmd,运行sb命令的时候,发现并不能像他人一样直接运行此命令。

在这里插入图片描述
在这里插入图片描述

你可能像下图一样:

在这里插入图片描述
在这里插入图片描述

1、你可以到这个你下载sb.exe的目录下去运行

在这里插入图片描述
在这里插入图片描述

可见,上面这种办法太笨了,而且当这个窗口关闭的时候,还需要去到这个目录下在可以。

当然了,打开cmd的姿势有很多种。

例如,我以前总结的:分享几个正确打开CMD的姿势,你知道几种?别人问你别再说不知道了,程序猿就要有程序猿的样子

如果打不开,可以复制这个链接:https://blog.csdn.net/qq_17623363/article/details/104394125

推荐看一下,一定会对你有帮助的。

2、可以配置环境变量,在哪里都可以运行

在这里插入图片描述
在这里插入图片描述

要记得保存!

保存完,要记得重新打开cmd!!

现在就可以做到了。

在这里插入图片描述
在这里插入图片描述

四、比较重要的参数

其中比较重要的参数大概有下列几个

  • -u 可用来指定要压测的网站或是API
  • -n 可用来指定要压的Request数量
  • -c 可用来指定Concurrent Request(并发请求)数量
  • -m 可用来指定要使用的HTTP Method
  • -h 可用来指定要显示HTTP Header
  • -q 可用来指定要显示Cookie
  • -N 指定运行的时间

其他的参数:

代码语言:javascript
复制
C:\Users\zhengsu>sb
SuperBenchmarker 4.5.1
Copyright (C) 2020 Ali Kheyrollahi
ERROR(S):
Required option 'u, url' is missing.

  -c, --concurrency            (Default: 1) Number of concurrent requests

  -n, --numberOfRequests       (Default: 100) Total number of requests

  -N, --numberOfSeconds        Number of seconds to run the test. If specified, -n will be ignored.

  -y, --delayInMillisecond     (Default: 0) Delay in millisecond

  -u, --url                    Required. Target URL to call. Can include placeholders.

  -m, --method                 (Default: GET) HTTP Method to use

  -t, --template               Path to request template to use

  -p, --plugin                 Name of the plugin (DLL) to replace placeholders. Should contain one class which
                               implements IValueProvider. Must reside in the same folder.

  -l, --logfile                Path to the log file storing run stats

  -f, --file                   Path to CSV file providing replacement values for the test

  -a, --TSV                    If you provide a tab-separated-file (TSV) with -f option instead of CSV

  -d, --dryRun                 Runs a single dry run request to make sure all is good

  -e, --timedField             Designates a datetime field in data. If set, requests will be sent according to order
                               and timing of records.

  -g, --TlsVersion             Version of TLS used. Accepted values are 0, 1, 2 and 3 for TLS 1.0, TLS 1.1 and TLS 1.2
                               and SSL3, respectively

  -v, --verbose                Provides verbose tracing information

  -b, --tokeniseBody           Tokenise the body

  -k, --cookies                Outputs cookies

  -x, --useProxy               Whether to use default browser proxy. Useful for seeing request/response in Fiddler.

  -q, --onlyRequest            In a dry-run (debug) mode shows only the request.

  -h, --headers                Displays headers for request and response.

  -z, --saveResponses          saves responses in -w parameter or if not provided in\response_<timestamp>

  -w, --responsesFolder        folder to save responses in if and only if -z parameter is set

  -?, --help                   Displays this help.

  -C, --dontcap                Don't Cap to 50 characters when Logging parameters

  -R, --responseRegex          Regex to extract from response. If it has groups, it retrieves the last group.

  -j, --jsonCount              Captures number of elements under the path e.g. root/leaf1/leaf2 finds count of leaf2
                               children - stores in the log as another parameter. If the array is at the root of the
                               JSON, use space: -j ' '

  -W, --warmUpPeriod           (Default: 0) Number of seconds to gradually increase number of concurrent users. Warm-up
                               calls do not affect stats.

  -P, --reportSliceSeconds     (Default: 3) Number of seconds as interval for reporting slices. E.g. if chosen as 5,
                               report charts have 5 second intervals.

  -F, --reportFolder           Name of the folder where report files get stored. By default it is in
                               yyyy-MM-dd_HH-mm-ss.ffffff of the start time.

  -B, --dontBrowseToReports    By default it, sb opens the browser with the report of the running test. If specified,
                               it wil not browse.

  -U, --shuffleData            If specified, shuffles the dataset provided by -f option.

  --help                       Display this help screen.

  --version                    Display version information.

System.Linq.Enumerable+<ExceptIterator>d__73`1[CommandLine.Error]

C:\Users\zhengsu>

五、经典示例

1、如果你想针对你的网站发送40个并发,并且跑30秒,你可以这样做:

sb -u http://127.0.0.1:8888 -c 40 -N 30

例如下面这个我拿www.baidu.com来跑的一次:

代码语言:javascript
复制
d:\soft\utils>sb -u http://www.baidu.com  -c 40 -N 30
Starting at 2020/11/29 23:41:49
[Press C to stop the test]
2087    (RPS: 54.4)
---------------Finished!----------------
Finished at 2020/11/29 23:42:28 (took 00:00:38.5613960)
2116    (RPS: 55.1)                     Status 200:    2116

RPS: 67.9 (requests/second)
Max: 5412ms
Min: 209ms
Avg: 569.7ms

  50%   below 462ms
  60%   below 512ms
  70%   below 602ms
  80%   below 697ms
  90%   below 891ms
  95%   below 1110ms
  98%   below 1754ms
  99%   below 2197ms
99.9%   below 4296ms
2117    (RPS: 55.1)
d:\soft\utils>

跑完之后就可以在浏览器看到结果:

在这里插入图片描述
在这里插入图片描述

可以看出每秒可处理多少的Request、最大的处理时间、最小的处理时间、平均的处理时间、以及压了这么多次的API,依比例分大概在哪个范围。

这些数值可以帮助我们评估网站或是API的性能与负载量。

除了看这些数据外,还可以利用JVM监控的工具来监控JVM的运行状况等。

最近在研究JVM方便的内容,我有整理JVM相关的几个工具,可以期待一下。

也可以同时监控服务器Server上的CPU Loading,磁盘IO,以及内存的使用状况,甚至可以用性能监视器拉些数值来看。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/11/29 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • sb测压工具
    • 文章目录
    • 一、简单介绍
    • 二、如何得到sb工具呢?
    • 三、如何随心所欲的使用sb工具?
    • 四、比较重要的参数
    • 五、经典示例
    相关产品与服务
    命令行工具
    腾讯云命令行工具 TCCLI 是管理腾讯云资源的统一工具。使用腾讯云命令行工具,您可以快速调用腾讯云 API 来管理您的腾讯云资源。此外,您还可以基于腾讯云的命令行工具来做自动化和脚本处理,以更多样的方式进行组合和重用。
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档