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

news2024/11/24 10:29:49

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)

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

docker启动卡死问题排查

问题&#xff1a;输入docker ps 或则vession 卡死&#xff0c;无任何输出 排查思路如下&#xff1a; 1、查看docker状态或者日志 journalctl -u docker.service 或者 systemctl status docker 3月 20 18:23:06 dfbpmyy2 dockerd[1114]: time"2024-03-20T18:23:06.7449…

mysql体系结构及主要文件

目录 1.mysql体系结构 2.数据库与数据库实例 3.物理存储结构​编辑 4.mysql主要文件 4.1数据库配置文件 4.2错误日志 4.3表结构定义文件 4.4慢查询日志 4.4.1慢查询相关参数 4.4.2慢查询参数默认值 4.4.3my.cnf中设置慢查询参数 4.4.4slow_query_log参数 4.4.…

【xr806开发板使用】连接wifi例程实现

##开发环境 win10 WSL ##1、环境配置 参考&#xff1a;https://aijishu.com/a/1060000000287513 首先下载安装wsl 和ubuntu https://docs.microsoft.com/zh-cn/windows/wsl/install &#xff08;1&#xff09;安装repo&#xff1a; 创建repo安装目录&#xff1a; mkdir ~/…

练习4-权重衰减(李沐函数简要解析)

环境:练习1的环境 代码详解 0.导入库 import torch from torch import nn from d2l import torch as d2l1.初始化数据 这里初始化出train_iter test_iter 可以查一下之前的获取Fashion数据集后的数据格式与此对应 n_train, n_test, num_inputs, batch_size 20, 100, 200, …

基于cnn深度学习的yolov5+pyqt+分类+resnet+骨龄检测系统

往期热门博客项目回顾&#xff1a; 计算机视觉项目大集合 改进的yolo目标检测-测距测速 路径规划算法 图像去雨去雾目标检测测距项目 交通标志识别项目 yolo系列-重磅yolov9界面-最新的yolo 姿态识别-3d姿态识别 深度学习小白学习路线 YOLOv5与骨龄识别 YOLOv5&a…

C语言指针与地址基础学习(取地址运算)

C语言指针与地址基础学习&#xff08;取地址运算&#xff09; 取地址运算&#xff1a;&运算符取得变量的地址代码示例一运算符& 取地址运算&#xff1a;&运算符取得变量的地址 代码示例一 #include<stdio.h> int main() {int a;a 6;printf("sizeof(i…

通过nginx配置文件服务器(浏览器访问下载)

配置服务器端文件下载和展示(Nginx) nginx.conf文件中增加配置&#xff0c;然后浏览器里访问ip:port回车即可 server { listen port; server_name 服务端ip; # 指定文件下载目录的路径 location / { # 使用root指令来设置文件的根目录 # Nginx会在该目录下寻找相对于loca…

【MySQL】-锁的使用

1、锁的粒度分类 1、全局锁 一般用于数据库备份&#xff0c;整个库只读 FLUSH TABLES WITH READ LOCK 2、表级锁 细分为&#xff1a; 1&#xff09;意向锁 Intention 事务A对表加行级锁&#xff0c;这行记录就只能读不能写。 事务B申请增加表级锁&#xff0c;如果他申请…

【Springboot3+Mybatis】文件上传阿里云OSS 基础管理系统CRUD

文章目录 一、需求&开发流程二、环境搭建&数据库准备三、部门管理四、员工管理4.1 分页(条件)查询4.2 批量删除员工 五、文件上传5.1 介绍5.2 本地存储5.3 阿里云OSS1. 开通OSS2. 创建存储空间Bucket 5.4 OSS快速入门5.5 OSS上传显示文件 六、配置文件6.1 yml配置6.2 C…

linux 命令笔记:gpustat

1 命令介绍 gpustat是一个基于Python的命令行工具&#xff0c;它提供了一种快速、简洁的方式来查看GPU的状态和使用情况它是nvidia-smi工具的一个封装&#xff0c;旨在以更友好和易于阅读的格式显示GPU信息。gpustat不仅显示基本的GPU状态&#xff08;如温度、GPU利用率和内存…

Oracle19C静默安装教程

文章目录 一、安装前的准备1、安装Linux操作系统2、配置网络源或者本地源3、hosts文件配置 二、准备安装环境1、安装依赖包2、创建oracle用户组3、配置系统内核参数4、关闭selinux5、配置oracle用户环境6、修改用户的Shell限制 三、静默安装Oracle数据库1、创建oracle安装目录2…

Oracle19C图形界面安装教程

文章目录 一、安装前的准备1、安装Linux操作系统2、配置网络源或者本地源3、hosts文件配置 二、Oracle19c安装过程1、安装相关软件&#xff1a;2、用户与组&#xff1a;3、修改内核参数&#xff1a;4、资源限制&#xff1a;5、配置用户环境变量&#xff1a;6、创建相关文件目录…

[pytorch] detr源码浅析

[pytorch] detr源码浅析 1. backbone部分2. encoder部分3. decoder部分4. 输出预测 为之后SAM的代码分析做铺垫 1. backbone部分 detr.py中的DETR class class DETR(nn.Module):def __init__(self, backbone, transformer, num_classes, num_queries, aux_lossFalse):...def …

21个 JVM 技术点详解(附面试解答)

最近兄弟们面试&#xff0c;都逃不过被 JVM 问题轰炸的命运&#xff0c;为啥面试官喜欢拿 JVM 说事呢&#xff1f;V 哥认为&#xff0c;除了要问倒你&#xff0c;就是要压你薪水&#xff0c;咱绝对不能怂&#xff0c;俗话说的好&#xff1a;兵来将挡&#xff0c;水来土掩&#…

串行通信协议 SPI

SPI&#xff08;Serial Peripheral Interface&#xff09;是一种串行通信协议&#xff0c;常用于连接微控制器、存储器、传感器和其他外围设备。SPI通常由一个主设备&#xff08;通常是微控制器&#xff09;和一个或多个从设备组成。 1、SPI通信一般由四根线组成: SCLK&#x…

2024 全新测算系统网站源码 二开修复完整版

源码介绍 安装教程 环境&#xff1a;程序为以PHPMYSQL架构&#xff0c;PHP版本5.6&#xff0c;让系统更畅快稳定。适合linux或者windows。 修改数据库/config/inc_config.php后导入数据库 子目录绑定ffsm 后台地址/acs 后台账号admin密码114077 支持功能&#xff1a;微信…

NO9 蓝桥杯单片机实践之串口通信的使用

1 回顾 串口通信的代码编写结构还是与中断一样&#xff0c;不同的是&#xff1a; 初始中断函数条件涉及到串口通信相关的寄存器和定时器1相关的寄存器&#xff08;定时器1用于产生波特率&#xff09;&#xff0c;但初始条件中的中断寄存器只考虑串口通信而不考虑定时器1。 vo…

利用 Claude 3 on Amazon Bedrock 和 Streamlit 的“终极组合”,开发智能对话体验

概述 通过本文&#xff0c;您将学会如何利用 Streamlit 框架快速搭建前端交互界面。该界面将集成图像上传功能&#xff0c;让用户可以方便地提交待处理图片。在后端&#xff0c;我们将借助 Amazon Bedrock 的 Message API&#xff0c;调用 Claude 3 家族中的 Sonnet 模型对图像…

Docker-镜像仓库

Docker ⛅Docker-Registry&#x1f320;分类&#x1f320;镜像仓库工作机制&#x1f320;常用的镜像仓库&#x1f320;镜像仓库命令☃️docker login☃️docker pull☃️docker push☃️docker search☃️docker logout &#x1f320;镜像命令[部分]☃️docker images☃️docke…

突破边界:Web3开启数字化社会的新纪元

引言 随着科技的不断进步和数字化社会的发展&#xff0c;Web3正逐渐成为了人们关注的焦点。作为新一代互联网的演进形态&#xff0c;Web3具有突破传统边界、实现去中心化的特点&#xff0c;被认为将开启数字化社会的新纪元。本文将深入探讨Web3的概念、特点、应用场景&#xf…