ab
命令是 Apache
的 Web
服务器的性能测试工具,它可以测试安装 Web
服务器每秒种处理的 HTTP
请求。
-A:指定连接服务器的基本的认证凭据;
-c:指定一次向服务器发出请求数;
-C:添加 cookie;
-g:将测试结果输出为 “gnuolot” 文件;
-h:显示帮助信息;
-H:为请求追加一个额外的头;
-i:使用 “head” 请求方式;
-k:激活 HTTP 中的 “keepAlive” 特性;
-n:指定测试会话使用的请求数;
-p:指定包含数据的文件;
-q:不显示进度百分比;
-T:使用 POST 数据时,设置内容类型头;
-v:设置详细模式等级;
-w:以 HTML 表格方式打印结果;
-x:以表格方式输出时,设置表格的属性;
-X:使用指定的代理服务器发送请求;
-y:以表格方式输出时,设置表格属性。
AB
压力测试一般关心两个选项 -c
-n
:
ab -c 100 -n 10000 http://127.0.0.1/index.php
-c 100
:并发量,当前为 100-n 10000
: 共发送 10000 个请求主要参考标准为 Requests per second
以及 Time per request
# 显示当前版本
This is ApacheBench, Version 2.3 <$Revision: 1796539 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking share.cuidanxia.com (be patient)
Completed 800 requests
SSL handshake failed (5).
Completed 1600 requests
SSL handshake failed (5).
SSL handshake failed (5).
Completed 2400 requests
Completed 3200 requests
SSL handshake failed (5).
SSL handshake failed (5).
Completed 4000 requests
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
Completed 4800 requests
SSL handshake failed (5).
SSL handshake failed (5).
Completed 5600 requests
SSL handshake failed (5).
Completed 6400 requests
SSL handshake failed (5).
Completed 7200 requests
SSL handshake failed (5).
SSL handshake failed (5).
Completed 8000 requests
Finished 8000 requests
# 服务器类型,基础链接,端口等基本信息
Server Software: nginx
Server Hostname: share.b.com
Server Port: 443
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256
TLS Server Name: share.b.com
# 请求的资源
Document Path: /
# 文档返回的长度,不包括相应头
Document Length: 2092 bytes
# 并发个数
Concurrency Level: 50
# 总请求时间
Time taken for tests: 453.640 seconds
# 总请求数
Complete requests: 8000
# 失败的请求数
Failed requests: 14
(Connect: 0, Receive: 0, Length: 14, Exceptions: 0)
Total transferred: 24270072 bytes
HTML transferred: 16706712 bytes
# 平均每秒的请求数
Requests per second: 17.64 [#/sec] (mean)
# 平均每个请求消耗的时间
Time per request: 2835.251 [ms] (mean)
# 就是上面的时间 除以并发数
Time per request: 56.705 [ms] (mean, across all concurrent requests)
# 时间传输速率
Transfer rate: 52.25 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1346 3378.4 541 59388
Processing: 12 1137 3465.7 465 63446
Waiting: 0 1038 2492.6 464 54887
Total: 45 2484 4834.0 1237 82256
# 就是有50%的请求都是在85ms内完成的
Percentage of the requests served within a certain time (ms)
50% 1237
66% 1967
75% 2469
80% 3045
90% 4561
95% 7556
98% 14256
99% 27311
100% 82256 (longest request)
本文为 Ellison 个人笔记,文章来自于网络或个人总结,转载无需和我联系,但请注明来自 Ellison`s Blog https://www.ruoxiaozh.com
Laravel 框架中前端如何使用 CSRF Laravel 5.6 单设备登录 Laravel 5.6 使用 UUID CURL 类封装 Laravel Eloquent 必备的实用技巧 提高安全性的最佳 Nginx 配置 Vagrant SSH 的登录总结 Laravel 跨域解决方案 CORS 跨域的概念与 TP5 的解决方案 MySQL 千万级大数据 SQL 查询优化技巧详解 数据库 30 条军规 JavaScript 判断访问客户端是 PC 端还是移动端 PHP 的笛卡尔积算法实现 API 文档编写 - APIDOC Linux MySQL 定时备份并上传到 git 仓库 Laravel 5.5 之 Api Resource Laravel 实现文章浏览次数统计 如何在 Laravel 项目中使用 Swagger 构建 Api 文档 如何编写基于 Swagger-PHP 的 API 文档 网站加载动画 Markdown 语法说明 见过世面的人,从不说这3句话 PHP7 新特性 - 完结篇 阿里云 Redis 开发规范 Nginx 负载均衡设置 PHP 生成随机红包算法 规范的 README 需要哪些内容 PHP 代码规范之 PSR-2 Ubuntu 14/16 下的 Laravel LNMP 线上环境自动部署脚本 PHP 闭包 不会,找人教你就够了? PHP 新特性 - 命名空间