centos7下ab测试(Apache Bench)

一、环境准备安装和命令查看

1、安装工具

yum install httpd-tools

[[email protected] ttt]# yum install httpd-tools
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-tools-2.4.6-40.el7.centos.4.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-tools-2.4.6-40.el7.centos.4.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing: httpd-tools x86_64 2.4.6-40.el7.centos.4 updates 83 k
Installing for dependencies:apr x86_64 1.4.8-3.el7 base 103 k
apr-util x86_64 1.5.2-6.el7 base 92 k

Transaction Summary
====================================================================================================================================
Install 1 Package (+2 Dependent packages)

Total download size: 278 k
Installed size: 584 k
Is this ok [y/d/N]: y
Downloading packages:
(1/3): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm | 83 kB 00:00:00
(2/3): apr-1.4.8-3.el7.x86_64.rpm                   | 103 kB 00:00:00
(3/3): apr-util-1.5.2-6.el7.x86_64.rpm              | 92 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------
Total 203 kB/s | 278 kB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.8-3.el7.x86_64 1/3
Installing : apr-util-1.5.2-6.el7.x86_64 2/3
Installing : httpd-tools-2.4.6-40.el7.centos.4.x86_64 3/3
Verifying : httpd-tools-2.4.6-40.el7.centos.4.x86_64 1/3
Verifying : apr-util-1.5.2-6.el7.x86_64 2/3
Verifying : apr-1.4.8-3.el7.x86_64 3/3

Installed:
httpd-tools.x86_64 0:2.4.6-40.el7.centos.4

Dependency Installed:
apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7

Complete!

2.ab测试的命令参数

ab: wrong number of arguments
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
    -n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make at a time
    -t timelimit    Seconds to max. to spend on benchmarking
                    This implies -n 50000
    -s timeout      Seconds to max. wait for each response
                    Default is 30 seconds
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -B address      Address to bind to when making outgoing connections
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header to use for POST/PUT data, eg.
                    ‘application/x-www-form-urlencoded‘
                    Default is ‘text/plain‘
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. ‘Apache=1234‘. (repeatable)
    -H attribute    Add Arbitrary header line, eg. ‘Accept-Encoding: gzip‘
                    Inserted after all normal header lines. (repeatable)
    -A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.
    -P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.
    -X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -q              Do not show progress when doing more than 150 requests
    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don‘t exit on socket receive errors.
    -h              Display usage information (this message)
    -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
    -f protocol     Specify SSL/TLS protocol
                    (SSL2, SSL3, TLS1, TLS1.1, TLS1.2 or ALL)

二、测试方案

1、模拟每秒50次并发请求

时间: 2024-08-10 21:23:11

centos7下ab测试(Apache Bench)的相关文章

PHP性能:序——谈ab(Apache Bench)压力测试工具

PHP性能:序--谈ab(Apache Bench)压力测试工具 ab(Apache  Bench)是啥? ab是Apache自带的一个压力测试软件,可以通过ab命令和选项对某个URL进行压力测试.ab建议在linux环境下使用. 为啥要压力测试工具? 因为你不给你的网站压力,你不知道项目的最大的容量是多少,自己的知识有多少.在一定范围里,压力达到一定程度,动力和容量也就达到顶峰.所以说没有最大的容量,只有极致的性能优化. 压力测试工具,另一方面也为测试提供一个标准,为当前需要优化提供基础数据.

后端开发都应该了解点接口的压力测试(Apache Bench版)

背景 小A:小B,最近调你的接口老是超时呀,8秒都还没返回结果,是不是有性能问题呀! 小B :我看看~~ 类似这样的对话,在现实中是时有发生的,不是特别严重的话,往往大家也不会去重视这个事. 尤其是在一些测试资源并不完备的,开发人员对性能测试没有接触过的一些公司,遇到这些会显得更加力不从心. 本着对自己写出来的东西负责,上线之前,我们都应该对自己的接口进行一个简单的压力测试. 其实做这一步也是为了让我们心里有个度,有个底,不至于说连能承受多少量都不知道.如果什么都不知道,那很容易陷入一个无底深渊

unbuntu 下ab 测试工具的安装使用

Apache Benchmark(ab) 一款由apache提供的压力测试软件 首先我们先安装 环境 sudo apt-get install apache2-utils //使用 用法:ab [options][http[s]://]hostname[:port]/path //  -n 请求数 -c 并发数 url 目标压测地址 ab -n100 -c10  //对百度进行 压力测试 This is ApacheBench, Version 2.3 <$Revision: 1528965 $

centos7下,解决Apache错误日志文件过大问题

1,日志文件太大问题 第一步:停止Apache服务的所有进程,删除 /var/log/httpd目录下的 error.log.access.log文件 第二步:打开 /etc/httpd/conf 的 httpd.conf配置文件 并找到下面配置 ErrorLog logs/error.log 把上面的注释掉,换成 # 每天生成一个错误日志文件 ErrorLog "|/usr/sbin/rotatelogs /var/log/httpd/error_log%Y%m%d.log 86400 480

CentOS7下fail2ban配合apache

官网地址:http://www.fail2ban.org/wiki/index.php/Main_Page download fail2ban-0.10.tar.gz,然后rz到服务器, tar -xvf fail2ban-0.10.tar.gz 进入解压后的目录,查看README [[email protected] tmp]# cd fail2ban-0.10/ [[email protected] fail2ban-0.10]# cat README.md #查看python版本是否满足

Linode 1G 1024 CentOS7+Apache+PHP 负载能力ab测试

使用的系统信息: [[email protected] ~]# uname -a Linux localhost.localdomain 3.15.4-x86_64-linode45 #1 SMP Mon Jul 7 08:42:36 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux [[email protected] ~]# php -v PHP 5.4.16 (cli) (built: Aug 6 2014 13:12:28) Copyright (c) 19

apache压力测试工具的apache bench和JMeter的安装

Apache压力测试工具的安装 1,apache bench的安装 apache  bench工具集成在http的软件包内,可以直接安装apache就可以. 当有些时候,我们不需要用到所有的软件包,我们只需要安装安装其中的某个组件就可以, 例如apache  bench这个组件. 首先安装ab运行需要的软件包apr-util yum install apr-util 然后安装一个yum的工具包,为了可以单独弄出来ab 新建一个目录  mkdir /test 切换目录  cd /test yumd

使用apache benchmark(ab) 测试报错汇总

1.socket: Too many open files (24) 解决方法: [[email protected] ~]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 14802 max locked memory (kby

利用Apache Bench进行压力测试(安装篇)

前言 API性能测试是企业级开发中非常重要的一环,API性能测试个人总结起来比较关注的两个点为: API在并发下是否会产生数据异常,比如秒杀系统的超买超卖 API极限情况下的QPS/TPS 目前比较流行的性能测试工具有LoaderRunner.Apache Bench.JMeter等,个人针对这三款性能测试工具都使用了一下,使用的感觉是: LoaderRunner是功能最强大的,压力测试后的各种报告什么都有,但是商用版本装一下时间比较长也比较麻烦,也有一定学习成本,上手用熟练需要一定时间 JMe