ab (Apache benchmark) - 压力/性能测试工具

Apache benchmark(ab)

  • 安装
    • window安装
      • 使用方法 - bin目录运行
      • 使用方法 - 任意目录运行
    • linux安装
  • 基本命令介绍
    • 常用参数:
    • 输出结果分析:
  • ab的man手册

安装

window安装

官网下载链接:https://www.apachehaus.com/cgi-bin/download.plx
在这里插入图片描述
下载完成得到zip包,如下:
在这里插入图片描述

使用方法 - bin目录运行

解压之后就可以使用了,不过要进入bin目录才可以使用ab.exe
例如ab的所在目录:D:\Downloads\httpd-2.4.55-o111s-x86-vs17\Apache24\bin
操作步骤:

  1. Win+R,输入cmd,然后回车,打开windows命令行窗口
  2. 进入到bin目录(具体操作见下图)
    在这里插入图片描述

使用方法 - 任意目录运行

配置环境变量可以更方便的使用ab命令,不用每次都到bin目录下运行
“我的电脑”右键 -> 属性 -> 高级系统设置 -> 环境变量 -> 编辑Path变量 -> 添加解压的bin文件夹路径 -> 确定
然后重启电脑就ok了。
在这里插入图片描述

linux安装

apt install apache2-utils		(for ubuntu)
yum install httpd-tools		(for centos)
ab -h		(验证是否安装成功)

基本命令介绍

ab(Apache Bench)是Apache自带的一个压力、性能测试工具,用于模拟多个并发访问,测试服务器的性能。 ab的使用格式如下:

ab [options] [http[s]://]hostname[:port]/path

常用参数:

  • -n: requests的总数;默认是1
  • -c: 并发数;默认是1
  • -t: 基准测试的最大描述,在固定的总时间内对服务器进行基准测试;默认没有时间限制
  • -s: socket超时前等待的最大时间;默认是30s
  • -p: POST请求发送的文件,也可以设置-T来起到相同的作用
  • -k: 开启HTTP KeepAlive,在一个HTTP会话中执行多个请求;默认不开启
  • -T: POST请求的content-type;默认是text/plain
  • -u: PUT请求发送的文件
  • -H: 自定义请求头
  • -f: 使用的SSL/TLS协议
  • -b: TCP发送/接收数据的缓冲区大小,单位是字节
  • -B: 在向外传输连接时绑定的本地地址
  • -i: 使用HEAD请求代替GET请求
  • -m: 定义HTTP请求的method
  • -v: 设置为4打印更详细的信息,设置为3打印响应码,设置为2打印warning、info信息
  • -w: 以HTML表格的格式打印结果

例如:向 http://www.baidu.com/发送10次请求,每次并发数为3
在这里插入图片描述

输出结果分析:

只例举个别的,详情参考ab的man手册

  • Document Length:第一个成功返回的Document的字节大小。如果在测试期间Document Length发生变化,则认为响应是错误的。
  • Concurrency Level:并发数
  • Time taken for tests:从创建第一个套接字连接到接收到最后一个响应所花费的时间(即整个测试过程的总时间)
  • Complete requests:完成的请求数量(收到的成功响应的数目)

ab的man手册

AB(1)                                                                                             ab                                                                                             AB(1)NAMEab - Apache HTTP server benchmarking toolSYNOPSISab [ -A auth-username:password ] [ -b windowsize ] [ -B local-address ] [ -c concurrency ] [ -C cookie-name=value ] [ -d ] [ -e csv-file ] [ -f protocol ] [ -g gnuplot-file ] [ -h ] [ -H cus‐tom-header ] [ -i ] [ -k ] [ -l ] [ -m HTTP-method ] [ -n requests ] [ -p POST-file ] [ -P proxy-auth-username:password ] [ -q ] [ -r ] [ -s timeout ] [ -S ] [ -t timelimit ]  [  -T  content-type  ]  [  -u  PUT-file  ]  [  -v  verbosity]  [  -V ] [ -w ] [ -x <table>-attributes ] [ -X proxy[:port] ] [ -y <tr>-attributes ] [ -z <td>-attributes ] [ -Z ciphersuite ] [http[s]://]host‐name[:port]/pathSUMMARYab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especiallyshows you how many requests per second your Apache installation is capable of serving.OPTIONS-A auth-username:passwordSupply  BASIC  Authentication  credentials  to  the  server. The username and password are separated by a single : and sent on the wire base64 encoded. The string is sent regardless ofwhether the server needs it (i.e., has sent an 401 authentication needed).-b windowsizeSize of TCP send/receive buffer, in bytes.-B local-addressAddress to bind to when making outgoing connections.-c concurrencyNumber of multiple requests to perform at a time. Default is one request at a time.-C cookie-name=valueAdd a Cookie: line to the request. The argument is typically in the form of a name=value pair. This field is repeatable.-d     Do not display the "percentage served within XX [ms] table". (legacy support).-e csv-fileWrite a Comma separated value (CSV) file which contains for each percentage (from 1% to 100%) the time (in milliseconds) it took to serve that percentage of the requests. This is  usu‐ally more useful than the 'gnuplot' file; as the results are already 'binned'.-f protocolSpecify SSL/TLS protocol (SSL2, SSL3, TLS1, TLS1.1, TLS1.2, or ALL). TLS1.1 and TLS1.2 support available in 2.4.4 and later.-g gnuplot-fileWrite  all  measured values out as a 'gnuplot' or TSV (Tab separate values) file. This file can easily be imported into packages like Gnuplot, IDL, Mathematica, Igor or even Excel. Thelabels are on the first line of the file.-h     Display usage information.-H custom-headerAppend extra headers to the request. The argument is typically  in  the  form  of  a  valid  header  line,  containing  a  colon-separated  field-value  pair  (i.e.,  "Accept-Encoding:zip/zop;8bit").-i     Do HEAD requests instead of GET.-k     Enable the HTTP KeepAlive feature, i.e., perform multiple requests within one HTTP session. Default is no KeepAlive.-l     Do not report errors if the length of the responses is not constant. This can be useful for dynamic pages. Available in 2.4.7 and later.-m HTTP-methodCustom HTTP method for the requests. Available in 2.4.10 and later.-n requestsNumber of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results.-p POST-fileFile containing data to POST. Remember to also set -T.-P proxy-auth-username:passwordSupply BASIC Authentication credentials to a proxy en-route. The username and password are separated by a single : and sent on the wire base64 encoded. The string is sent regardless ofwhether the proxy needs it (i.e., has sent an 407 proxy authentication needed).-q     When processing more than 150 requests, ab outputs a progress count on stderr every 10% or 100 requests or so. The -q flag will suppress these messages.-r     Don't exit on socket receive errors.-s timeoutMaximum number of seconds to wait before the socket times out. Default is 30 seconds. Available in 2.4.4 and later.-S     Do not display the median and standard deviation values, nor display the warning/error messages when the average and median are more than one or two times the standard deviation apart.And default to the min/avg/max values. (legacy support).-t timelimitMaximum  number  of seconds to spend for benchmarking. This implies a -n 50000 internally. Use this to benchmark the server within a fixed total amount of time. Per default there is no timelimit.-T content-typeContent-type header to use for POST/PUT data, eg. application/x-www-form-urlencoded. Default is text/plain.-u PUT-fileFile containing data to PUT. Remember to also set -T.-v verbositySet verbosity level - 4 and above prints information on headers, 3 and above prints response codes (404, 200, etc.), 2 and above prints warnings and info.-V     Display version number and exit.-w     Print out results in HTML tables. Default table is two columns wide, with a white background.-x <table>-attributesString to use as attributes for <table>. Attributes are inserted <table here >.-X proxy[:port]Use a proxy server for the requests.-y <tr>-attributesString to use as attributes for <tr>.-z <td>-attributesString to use as attributes for <td>.-Z ciphersuiteSpecify SSL/TLS cipher suite (See openssl ciphers)OUTPUTThe following list describes the values returned by ab:Server SoftwareThe value, if any, returned in the server HTTP header of the first successful response. This includes all characters in the header from beginning to the point a character with  decimalvalue of 32 (most notably: a space or CR/LF) is detected.Server HostnameThe DNS or IP address given on the command lineServer PortThe port to which ab is connecting. If no port is given on the command line, this will default to 80 for http and 443 for https.SSL/TLS ProtocolThe protocol parameters negotiated between the client and server. This will only be printed if SSL is used.Document PathThe request URI parsed from the command line string.Document LengthThis is the size in bytes of the first successfully returned document. If the document length changes during testing, the response is considered an error.Concurrency LevelThe number of concurrent clients used during the testTime taken for testsThis is the time taken from the moment the first socket connection is created to the moment the last response is receivedComplete requestsThe number of successful responses receivedFailed requestsThe  number  of  requests that were considered a failure. If the number is greater than zero, another line will be printed showing the number of requests that failed due to connecting, reading, incorrect content length, or exceptions.Write errorsThe number of errors that failed during write (broken pipe).Non-2xx responsesThe number of responses that were not in the 200 series of response codes. If all responses were 200, this field is not printed.Keep-Alive requestsThe number of connections that resulted in Keep-Alive requestsTotal body sentIf configured to send data as part of the test, this is the total number of bytes sent during the tests. This field is omitted if the test did not include a body to send.Total transferredThe total number of bytes received from the server. This number is essentially the number of bytes sent over the wire.HTML transferredThe total number of document bytes received from the server. This number excludes bytes received in HTTP headersRequests per secondThis is the number of requests per second. This value is the result of dividing the number of requests by the total time takenTime per requestThe average time spent per request. The first value is calculated with the formula concurrency * timetaken * 1000 / done while the second value is calculated with the formula timetaken* 1000 / doneTransfer rateThe rate of transfer as calculated by the formula totalread / 1024 / timetakenBUGSThere  are  various  statically declared buffers of fixed length. Combined with the lazy parsing of the command line arguments, the response headers from the server and other external inputs,this might bite you.It does not implement HTTP/1.x fully; only accepts some 'expected' forms of responses. The rather heavy use of strstr(3) shows up top in profile, which might indicate a  performance  problem;i.e., you would measure the ab performance rather than the server's.Apache HTTP Server                                                                            2015-05-01                                                                                         AB(1)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/281530.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【LinuxC】C语言线程(pthread)

文章目录 一、 POSIX 线程库1.1 POSIX标准1.2 Pthreads1.2 数据类型、函数、宏1.21 数据类型1.22 函数1.23 宏 二、创建线程三、线程同步四、线程销毁五、示例5.1 完整示例5.2 信号量示例 本专栏上一篇文章是Windows下&#xff08;MSVC&#xff09;的线程编程&#xff0c;需要的…

[实践经验]: visual studio code 实用技巧

目录 editor rulers 这里主要总结一些常用的VScode技巧&#xff0c;不定时更新… editor rulers 设置 -> 搜索 editor.rulers -> edit in settings.json "editor.rulers": [{"column": 80,"color": "#ff00FF"},]效果如图

Linux:设置别名命令alias

相关阅读 Linuxhttps://blog.csdn.net/weixin_45791458/category_12234591.html?spm1001.2014.3001.5482 在Linux中alias命令用于为一串字符&#xff08;常代表命令&#xff09;设置一个别名&#xff0c;该别名在Bash读取并解析一行命令时会被展开。 下面是该命令的语法与选项…

python(django)之产品后台管理功能实现

1、添加新项目 在命令行输入以下代码 python manage.py startapp prroduct 2、添加路径和代码结构 在新项目目录下admin.py中加入以代码 from .models import Product class ProductAdmin(admin.ModelAdmin):list_display [product_name, product_desc,producter,created_…

牛客小白月赛86(D剪纸游戏)

题目链接:D-剪纸游戏_牛客小白月赛86 (nowcoder.com) 题目描述: 输入描述: 输入第一行包含两个空格分隔的整数分别代表 n 和 m。 接下来输入 n行&#xff0c;每行包含 m 个字符&#xff0c;代表残缺纸张。 保证&#xff1a; 1≤n,m≤10001 字符仅有 . 和 * 两种字符&#xf…

利用autodl服务器跑模型

1. 租用服务器 本地改模型 服务器 将改进好的、数据集处理好的模型压缩为zip文件上传到阿里云盘打开服务器AUTODL服务器&#xff0c;在主页中选择容器实例 在此位置进行开关机操作&#xff0c;若停止服务器&#xff0c;必须关机&#xff0c;不然会一直扣钱 2. 运行模型 选择…

Nacos详解,从安装到服务部署,及nginx反向代理

Nacos 安装 Windows安装 下载 在Nacos的GitHub页面&#xff0c;提供有下载链接&#xff0c;可以下载编译好的Nacos服务端或者源代码&#xff1a; GitHub主页&#xff1a;https://github.com/alibaba/nacos GitHub的Release下载页&#xff1a;https://github.com/alibaba/nacos…

peft模型微调_IA3

IA3&#xff08;论文&#xff1a;Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learning&#xff09;&#xff0c;通过学习向量来对激活层加权进行缩放&#xff0c;从而获得更强的性能&#xff0c;同时仅引入相对少量的新参数&#xff0c;…

鸿蒙:@Observed装饰器和@ObjectLink装饰器:嵌套类对象属性变化

在实际应用开发中&#xff0c;应用会根据开发需要&#xff0c;封装自己的数据模型。对于多层嵌套的情况&#xff0c;比如二维数组&#xff0c;或者数组项class&#xff0c;或者class的属性是class&#xff0c;他们的第二层的属性变化是无法观察到的。这就引出了Observed/Object…

【文末附gpt升级4.0方案】FastGPT详解

FastGPT知识库结构讲解 FastGPT是一个基于GPT模型的知识库&#xff0c;它的结构可以分为以下几个部分&#xff1a; 1. 数据收集&#xff1a;FastGPT的知识库是通过从互联网上收集大量的文本数据来构建的。这些数据可以包括维基百科、新闻文章、论坛帖子等各种类型的文本。 2…

转置卷积(transposed-conv)

一、什么是转置卷积 1、转置卷积的背景 通常&#xff0c;对图像进行多次卷积运算后&#xff0c;特征图的尺寸会不断缩小。而对于某些特定任务 (如图像分割和图像生成等)&#xff0c;需将图像恢复到原尺寸再操作。这个将图像由小分辨率映射到大分辨率的尺寸恢复操作&#xff0c…

聚类算法( clustering algorithm):

在前两章&#xff0c;我们学的是&#xff1a;线性回归&#xff0c;逻辑回归&#xff0c;深度学习(神经网络)&#xff0c;决策树&#xff0c;随即森林算法。他们都是监督学习的例子。 在这一章里&#xff0c;我们将学习非监督学习的算法。 什么是聚类算法&#xff1a; 聚类算…

Excel 使用SQL统计表格数据

一. 需求 ⏹有如下Excel表格&#xff0c;现要求统计每个店铺的每种类别的商品总销量和最大销量 ⏹详细数据如下 店铺商品类别销量一山店苹果水果27729一山店梨水果76175一山店菠萝水果14699一山店香蕉水果61371一山店西兰花蔬菜72822一山店大白菜蔬菜65090一山店小白菜蔬菜13…

git的下载与安装

下载 首先&#xff0c;打开您的浏览器&#xff0c;并输入Git的官方网站地址 点击图标进行下载 下载页面会列出不同操作系统和平台的Git安装包。根据您的操作系统&#xff08;Windows、macOS、Linux等&#xff09;和位数&#xff08;32位或64位&#xff09;&#xff0c;选择适…

k8s系列之十五 Istio 部署Bookinfo 应用

Bookinfo 应用中的几个微服务是由不同的语言编写的。 这些服务对 Istio 并无依赖&#xff0c;但是构成了一个有代表性的服务网格的例子&#xff1a;它由多个服务、多个语言构成&#xff0c;并且 reviews 服务具有多个版本。 该应用由四个单独的微服务构成。 这个应用模仿在线书…

[Halcon学习笔记]标定常用的Halcon标定板规格及说明

1、介绍 大多数标定的要求都是以实心圆或方格来作为标志点&#xff0c;所以一般的标定板为棋盘格或矩阵圆点图&#xff0c;高精度的相机标定过程中&#xff0c;大多是以比较明确的特征点来作为参考&#xff0c;所以通过识别标定板的圆形&#xff0c;拟合出精确的中心位置&…

【面试题】HashMap为什么可以插入null而Hashtable就不可以(源码分析)

首先hashmap可以插入null值&#xff0c;但是hashtable和hashcurrentHashmap是不支持的&#xff1b;这是因为在 hashmap对插入key为null进行了特殊处理&#xff0c;当插入的值为null的时候会将哈希值设置为0 但是hashtable会直接抛出异常&#xff1a; 并且hashmap是线程不…

基于C/C++的easyx图形库教程

文章目录: 一&#xff1a;前言 二&#xff1a;窗口&#xff08;宽高 背景颜色 窗口标题 弹出对话框&#xff09; 三&#xff1a;图形绘制&#xff08;点 线 矩形 圆 椭圆&#xff09; 四&#xff1a;文字&#xff08;颜色 大小 背景 位置 打印 文字居中&#xff09; 五&a…

Jest:JavaScript的单元测试利器

&#x1f90d; 前端开发工程师、技术日更博主、已过CET6 &#x1f368; 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 &#x1f560; 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 &#x1f35a; 蓝桥云课签约作者、上架课程《Vue.js 和 E…

IDEA创建Sping项目只能勾选17和21,没有Java8?

解决办法: 替换创建项目的源 我们只知道IDEA页面创建Spring项目&#xff0c;其实是访问spring initializr去创建项目。故我们可以通过阿里云国服去间接创建Spring项目。将https://start.spring.io/或者http://start.springboot.io/替换为 https://start.aliyun.com/