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)

NAME
       ab - Apache HTTP server benchmarking tool

SYNOPSIS
       ab [ -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]/path

SUMMARY
       ab 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 especially
       shows you how many requests per second your Apache installation is capable of serving.

OPTIONS
       -A auth-username:password
              Supply  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 of
              whether the server needs it (i.e., has sent an 401 authentication needed).

       -b windowsize
              Size of TCP send/receive buffer, in bytes.

       -B local-address
              Address to bind to when making outgoing connections.

       -c concurrency
              Number of multiple requests to perform at a time. Default is one request at a time.

       -C cookie-name=value
              Add 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-file
              Write 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 protocol
              Specify 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-file
              Write  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. The
              labels are on the first line of the file.

       -h     Display usage information.

       -H custom-header
              Append 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-method
              Custom HTTP method for the requests. Available in 2.4.10 and later.

       -n requests
              Number 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-file
              File containing data to POST. Remember to also set -T.

       -P proxy-auth-username:password
              Supply 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 of
              whether 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 timeout
              Maximum 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 timelimit
              Maximum  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-type
              Content-type header to use for POST/PUT data, eg. application/x-www-form-urlencoded. Default is text/plain.

       -u PUT-file
              File containing data to PUT. Remember to also set -T.

       -v verbosity
              Set 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>-attributes
              String to use as attributes for <table>. Attributes are inserted <table here >.

       -X proxy[:port]
              Use a proxy server for the requests.

       -y <tr>-attributes
              String to use as attributes for <tr>.

       -z <td>-attributes
              String to use as attributes for <td>.

       -Z ciphersuite
              Specify SSL/TLS cipher suite (See openssl ciphers)

OUTPUT
       The following list describes the values returned by ab:

       Server Software
              The 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  decimal
              value of 32 (most notably: a space or CR/LF) is detected.

       Server Hostname
              The DNS or IP address given on the command line

       Server Port
              The 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 Protocol
              The protocol parameters negotiated between the client and server. This will only be printed if SSL is used.

       Document Path
              The request URI parsed from the command line string.

       Document Length
              This 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 Level
              The number of concurrent clients used during the test

       Time taken for tests
              This is the time taken from the moment the first socket connection is created to the moment the last response is received

       Complete requests
              The number of successful responses received

       Failed requests
              The  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 errors
              The number of errors that failed during write (broken pipe).

       Non-2xx responses
              The 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 requests
              The number of connections that resulted in Keep-Alive requests

       Total body sent
              If 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 transferred
              The total number of bytes received from the server. This number is essentially the number of bytes sent over the wire.

       HTML transferred
              The total number of document bytes received from the server. This number excludes bytes received in HTTP headers

       Requests per second
              This is the number of requests per second. This value is the result of dividing the number of requests by the total time taken

       Time per request
              The 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 / done

       Transfer rate
              The rate of transfer as calculated by the formula totalread / 1024 / timetaken

BUGS
       There  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)

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

鸿蒙Harmony应用开发—ArkTS-高级组件:@ohos.arkui.advanced.Chip(操作块组件)

操作块&#xff0c;用于搜索框历史记录或者邮件发送列表等场景。 说明&#xff1a; 该组件从API Version 11开始支持。后续版本如有新增内容&#xff0c;则采用上角标单独标记该内容的起始版本。 子组件 无 Chip Chip({options:ChipOptions}) 装饰器类型&#xff1a;Builde…

软考高级:软件架构风格-数据流风格概念和例题

作者&#xff1a;明明如月学长&#xff0c; CSDN 博客专家&#xff0c;大厂高级 Java 工程师&#xff0c;《性能优化方法论》作者、《解锁大厂思维&#xff1a;剖析《阿里巴巴Java开发手册》》、《再学经典&#xff1a;《Effective Java》独家解析》专栏作者。 热门文章推荐&am…

用户登录项目JAVA简单实现

1、“zhangsan”.equals&#xff08;userName&#xff09; 把常量放在前面是为了防止空指针、 2、session不用我们担心会不会空指针&#xff0c;如果为null会为我们创建个空的session 3、网页清缓存 &#xff08;1&#xff09;ctrlF5 &#xff08;2&#xff09;ctrlshiftdel…

FPGA学习_时序分析

文章目录 前言一、组合逻辑与时序逻辑二、建立时间和保持时间三、建立时间和保持时间 前言 心中有电路&#xff0c;下笔自然神&#xff01;&#xff01;&#xff01; 一、组合逻辑与时序逻辑 组合逻辑&#xff1a;没有时钟控制的数字电路&#xff0c;代码里的判断逻辑都是组…

浅析扩散模型与图像生成【应用篇】(九)——UNIT-DDPM

10. UNIT-DDPM: UNpaired Image Translation with Denoising Diffusion Probabilistic Models 该文提出一种基于DDPM的非配对的图像转换方法&#xff0c;称为UNIT-DDPM&#xff0c;能够实现源域的图像到目标域图像的转换&#xff0c;在保留原有图像内容的同时&#xff0c;转换为…

现货黄金做对冲的具体方法

现货黄金做对冲的具体方法是运用金融衍生工具和策略&#xff0c;以减轻或消除持有现货黄金所面临的市场风险。具体而言&#xff0c;投资者可通过期货合约、期权、掉期等金融工具来实现对冲&#xff0c;保障其投资价值不受金价波动的负面影响。 &#xfeff; 期货合约在对冲中…

让数据在两个buckets之间传输 - Google Storage Transfer Service

在业务场景中&#xff0c; 有时我们不想直接暴露数据存储空间给上游系统&#xff0c; 而需要设置1个landing Path 让上游系统发送数据 如图&#xff1a; 我们只需grant landing bucket 的权限给上游系统&#xff0c; 而上游系统是访问不了storage bucket的保证了数据隔离 但是…

vue3与Electron构建跨平台应用(webpack)

一、创建vue3项目 vue create vue3_webpack_electron 二、安装Electron npm install --save-dev electron Electron 三、vue add electron-builder vue add electron-builder

RK3568平台开发系列讲解(pinctrl篇)pinctrl 子系统函数操作集

🚀返回专栏总目录 文章目录 一、pinctrl_ops二、pinctrl_ops三、pinconf_ops沉淀、分享、成长,让自己和他人都能有所收获!😄 在 pinctrl_desc 结构体中总共有三个函数操作集, 具体内容如下所示: const struct pinctrl_ops *pctlops; // 引脚控制操作函数指针 const

【机器学习】基于萤火虫算法优化的BP神经网络分类预测(FA-BP)

目录 1.原理与思路2.设计与实现3.结果预测4.代码获取 1.原理与思路 【智能算法应用】智能算法优化BP神经网络思路【智能算法】萤火虫算法&#xff08;FA&#xff09;原理及实现 2.设计与实现 数据集&#xff1a; 多输入多输出&#xff1a;样本特征24&#xff0c;标签类别4。…

html常见标签

width宽度 height高度 border边框 1px&#xff08;边框线条宽度&#xff09; solid&#xff08;实线&#xff09; red&#xff08;红色&#xff09; border-radius: 100px 边框圆角 background-color&#xff1a;red&#xff08;背景颜色为红色&#xff09; margin&#xf…

STL_list文档使用介绍与底层代码实现简介

文章目录 list介绍list的使用构造函数&#xff08;constructor&#xff09;迭代器list capacitylist modify&#xff08;修改&#xff09;其他接口函数list迭代器失效问题 list实现基础框架(节点类&#xff09;基础框架&#xff08;迭代器类&#xff09;基础框架&#xff08;链…

提供数字免疫力:采取整体方法来优化您的网络

采用数字技术已成为许多美国企业的关键竞争优势&#xff0c;导致其在与新部署的云解决方案的安全连接方面的投资不断增加。然而&#xff0c;随着越来越多的关键应用程序迁移到云端&#xff0c;公司保护其敏感数据和资源变得更具挑战性&#xff0c;因为这些资产现在超出了内部防…

uniapp——第3篇:自定义组件、组件间传数据

前提&#xff0c;建议先学会前端几大基础&#xff1a;HTML、CSS、JS、Ajax&#xff0c;还有一定要会Vue!&#xff08;Vue2\Vue3&#xff09;都要会&#xff01;&#xff01;&#xff01;不然不好懂 一、组件是啥玩意&#xff1f; 我之前讲vue2的文章讲过 Vue全家桶:vue2vue3全…

Python通过Ctypes调用C++类,实测有效

文章目录 前言创建vs dll工程添加外部库编辑代码编译测试参考 前言 在软件开发中&#xff0c;有时候需要Python与C相结合&#xff0c;以充分发挥两者的优势 。Python作为一种高级编程语言&#xff0c;具有简洁易读的特点&#xff0c;适用于快速开发和原型设计。而C则是一种性能…

小程序绕过 sign 签名

之前看到了一篇文章【小程序绕过sign签名思路】之前在做小程序渗透时也遇到了这种情况&#xff0c;但是直接放弃测试了&#xff0c;发现这种思路后&#xff0c;又遇到了这种情况&#xff0c;记录下过程。 并没有漏洞分享&#xff0c;仅仅是把小程序也分享出来&#xff0c;方便…

上位机图像处理和嵌入式模块部署(qmacvisual轮廓查找)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 前面我们说过&#xff0c;图像的处理流程一般都是这样的&#xff0c;即灰度化-》降噪-》边缘检测-》二值化-》开闭运算-》轮廓检测。虽然前面的几个…

AI开源概览及工具使用

一、前言 随着ChatGPT热度的攀升&#xff0c;越来越多的公司也相继推出了自己的AI大模型&#xff0c;如文心一言、通义千问等。各大应用也开始内置AI玩法&#xff0c;如抖音的AI特效&#xff1b; 关联资源&#xff1a;代码 GitHub、相关论文、项目Demo、产品文档、Grok Ai、gr…

多数据源 - dynamic-datasource | 进阶 - 动态添加、移除数据源

文章目录 实现原理示例程序🗯️ 上节回顾:前节中,了解了 dynamic-datasource 的事务支持。 👉 本节目标:了解 dynamic-datasource 的进阶用法 - 动态添加/移除数据源。 动态添加/移除数据源:指在系统运行过程中动态的添加数据源,删除数据源,多使用于基于数据库的多租…

探讨苹果 Vision Pro 的空间视频(术语辨析、关键技术、思考)

背景:一位资深视频技术从业者在 Pixvana 工作,积累了丰富的捕获、处理、编码、流传和播放空间媒体经验。 一、术语 空间视频:传统的 3D 视频,呈矩形,包含左右眼视图,如 iPhone15 Pro 和 Vision Pro 可录制。沉浸式视频:非矩形的环绕式视频体验,通常由两个或多个传感器…