测试工具: Apache Benchmark(ab)安装

本文介绍了Apache Benchmark(ab)的安装过程,包括依赖环境的安装,如pcre和apr。详细讲解了如何使用ab进行压力测试,包括基础设置参数、命令示例和结果分析。同时,还展示了如何编写基于ab的通用测试脚本及其参数说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Apache Benchmark 简称ab,是apache里一个压力测试工具。安装ab一种直接安装apache server即可里面自带ab服务;另外一种不安装apache server 直接安装ab;

这里是通过安装apache server 环境是centos7

1:先安装基础依赖环境:

1.1:依赖基础环境

yum install -y gcc gcc-c++

yum install -y openssl-devel expat-devel

 

1.2:安装 pcre tar下载地址ftp://ftp.pcre.org/pub/pcre/

##安装基础依赖包
# yum -y install openssl-devel 

##安装pcre 这里使用版本是8.43
tar -vxf pcre-8.43.tar.gz
cd  pcre-8.43
##配置
./configure --prefix=/usr/local/pcre-8.43
##编译安装
make && make install 

1.3:安装apr tar包下载地址http://archive.apache.org/dist/apr/

##先安装APR 这里使用apr版本为1.7.0 
tar -vxf apr-1.7.0.tar.gz
cd apr-1.7.0
##配置
./configure --prefix=/usr/local/apr-1.7.0
##编译安装
make && make install    
##安装
##这里使用apr-utils版本为1.6.1
tar -vxf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
##配置
./configure --prefix=/usr/local/apr-util-1.6.1 --with-apr=/usr/local/apr-1.7.0/
##编译安装
make && make install

1.4:安装 apache server

直接在官网中下载最新版的tar包路径为:http://httpd.apache.org/download.cgi#apache24

##apache 版本为httpd-2.4.41
tar -vxf httpd-2.4.41.tar.gz
cd 	httpd-2.4.41
###配置 参数--prefix指定安装路径,--enable-mods-shared启用所有支持的动态加载模块,--with-apr指定APR路径,--with-apr-util指定APR-util路径 --with-pcre指定pcre路径
./configure --prefix=/usr/local/apache --enable-mods-shared=all --with-apr=/usr/local/apr-1.7.0/ --with-apr-util=/usr/local/apr-util-1.6.1/ --with-pcre=/usr/local/pcre-8.43  
##安装
make && make install


2:使用apache ab模块

2.1:ab 基础设置参数说明:

    -n requests     要执行的请求总数
    -c concurrency  并发数
    -t timelimit    所有请求数共花最大时间
    -s timeout      最大超时时间 默认30s
    -T Content Type 设置Content Type 例如 -T‘application/json’
    -p postfile     POST请求时请求参数可以放在文件中由postfile指定路径. Remember also to set -T

ab命令支持所有参数

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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值