热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Apache自带ab性能测试工具学习

目前大多数测试人员喜欢使用具有图形界面的Loadrunner作为web的性能测试工具,其实在Linux系统上有很多开源的性能测试工具很好,而且这些工具很小,又是开源产品。对与测试人员来是一个很好的选择。以前在做web性能测试的时候,使用了一段时间ab工具,但是

目前大多数测试人员喜欢使用具有图形界面的Loadrunner作为web的性能测试工具,其实在Linux系统上有很多开源的性能测试工具很好,而且这些工具很小,又是开源产品。对与测试人员来是一个很好的选择。

以前在做web性能测试的时候,使用了一段时间ab工具,但是一直没有整理出来,知识就没有积累下来。

(1)ab工具位置

一般情况下在Apache的bin目录下,但也不排除在其它目录,目前我使用的Ubuntu Server 11.04,使用apt-get安装的apache2,ab就没有在apache2目录下,而是在/usr/bin目录下。见下图

(2)ab的基本格式

NAME
       ab - Apache HTTP server benchmarking tool

SYNOPSIS
       ab  [ -A auth-username:password ] [ -b windowsize ] [ -c concurrency ] [ -C COOKIE-name=value ] [ -d ] [ -e csv-file ] [ -f protocol ] [ -g gnuplot-file ] [ -h ] [ -H custom-header ] [ -i ]
       [ -k ] [ -n requests ] [ -p POST-file ] [ -P proxy-auth-username:password ] [ -q ] [ -r ] [ -s ] [ -S ] [ -t timelimit ] [ -T content-type ] [ -u PUT-file ] [ -v verbosity] [ -V ] [ -w ]  [
       -x

-attributes ] [ -X proxy[:port] ] [ -y -attributes ] [ -z
-attributes ] [ -Z ciphersuite ] [http[s]://]hostname[: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 espe-
       cially 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.

       -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
              usually more useful than the 'gnuplot' file; as the results are already 'binned'.

       -f protocol
              Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL).

       -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.


       -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     When  compiled  in (ab -h will show you) use the SSL protected https rather than the http protocol. This feature is experimental and very rudimentary. You probably do not want to use
              it.

       -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: 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

-attributes
              String to use as attributes for
. Attributes are inserted
.

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

       -y -attributes
              String to use as attributes for .

       -z

-attributes
              String to use as attributes for
.

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

(3)ab常用的情况以及相应的参数含义


推荐阅读
  • Webmin远程命令执行漏洞复现及防护方法
    本文介绍了Webmin远程命令执行漏洞CVE-2019-15107的漏洞详情和复现方法,同时提供了防护方法。漏洞存在于Webmin的找回密码页面中,攻击者无需权限即可注入命令并执行任意系统命令。文章还提供了相关参考链接和搭建靶场的步骤。此外,还指出了参考链接中的数据包不准确的问题,并解释了漏洞触发的条件。最后,给出了防护方法以避免受到该漏洞的攻击。 ... [详细]
  • Skywalking系列博客1安装单机版 Skywalking的快速安装方法
    本文介绍了如何快速安装单机版的Skywalking,包括下载、环境需求和端口检查等步骤。同时提供了百度盘下载地址和查询端口是否被占用的命令。 ... [详细]
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 本文介绍了Linux系统中正则表达式的基础知识,包括正则表达式的简介、字符分类、普通字符和元字符的区别,以及在学习过程中需要注意的事项。同时提醒读者要注意正则表达式与通配符的区别,并给出了使用正则表达式时的一些建议。本文适合初学者了解Linux系统中的正则表达式,并提供了学习的参考资料。 ... [详细]
  • Ubuntu 9.04中安装谷歌Chromium浏览器及使用体验[图文]
    nsitionalENhttp:www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd ... [详细]
  • 如何实现织梦DedeCms全站伪静态
    本文介绍了如何通过修改织梦DedeCms源代码来实现全站伪静态,以提高管理和SEO效果。全站伪静态可以避免重复URL的问题,同时通过使用mod_rewrite伪静态模块和.htaccess正则表达式,可以更好地适应搜索引擎的需求。文章还提到了一些相关的技术和工具,如Ubuntu、qt编程、tomcat端口、爬虫、php request根目录等。 ... [详细]
  • Linuxchmod目录权限命令图文详解在Linux文件系统模型中,每个文件都有一组9个权限位用来控制谁能够读写和执行该文件的内容。对于目录来说,执行位的作用是控制能否进入或者通过 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 这是原文链接:sendingformdata许多情况下,我们使用表单发送数据到服务器。服务器处理数据并返回响应给用户。这看起来很简单,但是 ... [详细]
  • 如何去除Win7快捷方式的箭头
    本文介绍了如何去除Win7快捷方式的箭头的方法,通过生成一个透明的ico图标并将其命名为Empty.ico,将图标复制到windows目录下,并导入注册表,即可去除箭头。这样做可以改善默认快捷方式的外观,提升桌面整洁度。 ... [详细]
  • Windows下配置PHP5.6的方法及注意事项
    本文介绍了在Windows系统下配置PHP5.6的步骤及注意事项,包括下载PHP5.6、解压并配置IIS、添加模块映射、测试等。同时提供了一些常见问题的解决方法,如下载缺失的msvcr110.dll文件等。通过本文的指导,读者可以轻松地在Windows系统下配置PHP5.6,并解决一些常见的配置问题。 ... [详细]
  • 本文介绍了在Win10上安装WinPythonHadoop的详细步骤,包括安装Python环境、安装JDK8、安装pyspark、安装Hadoop和Spark、设置环境变量、下载winutils.exe等。同时提醒注意Hadoop版本与pyspark版本的一致性,并建议重启电脑以确保安装成功。 ... [详细]
  • 本文介绍了在Windows环境下如何配置php+apache环境,包括下载php7和apache2.4、安装vc2015运行时环境、启动php7和apache2.4等步骤。希望对需要搭建php7环境的读者有一定的参考价值。摘要长度为169字。 ... [详细]
  • 本文介绍了一些Java开发项目管理工具及其配置教程,包括团队协同工具worktil,版本管理工具GitLab,自动化构建工具Jenkins,项目管理工具Maven和Maven私服Nexus,以及Mybatis的安装和代码自动生成工具。提供了相关链接供读者参考。 ... [详细]
author-avatar
有你世界就很美_484
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有