使用Apache ab进行http性能测试
Mac自带了Apache环境
打开“终端(terminal)”,输入 sudo apachectl -v,(可能需要输入机器秘密)。如下显示Apache的版本
接着输入 sudo apachectl start,这样Apache就启动了。打开Safari浏览器地址栏输入 “http://localhost”,可以看到内容为“It works!”的页面。其位于“/Library(资源库)/WebServer/Documents/”下,这就是Apache的默认根目录。
Apache的安装目录在:/etc/apache2/,etc默认是隐藏的。有三种方式查看:
- dock下右键Finder,选择"前往文件夹",输入"/etc"
- 在finder下----》前往---》前往文件夹,然后输入/etc
- 可以在terminal 输入 "open /etc"
windows可以去http://httpd.apache.org/download.cgi下载,或者从命令行安装
1. 安装apache
sudo port install apache2
启动apache: sudo apachectl start
2. brew install pcre
3. wget http://ftp.yz.yamagata-u.ac.jp/pub/network/apache//httpd/httpd-2.4.4.tar.bz2
(1)解压
(2) ./configure
(3) make && make install
(4) sudo cp support/ab /usr/sbin
4. ab -n 1000 -c 10 http://localhost:3000/ 最后这个斜杠不能少
这个ab -n1000 -c10 http://localhost:3000/命令,在window系统下,需要先用cd命令定位到你的apache安装目录的bin文件夹。。。
ab的参数说明
-n 需要执行的请求次数
-c 并发的数量
-t 等待返回的最长时间
-b TCP收发缓冲区的大小,单位(byte)
-p 使用post (同时需要定义-T参数)
-u 使用put (同时需要定义-T参数)
-T content-type, 例如application/x-www-form-urlencoded, 默认为text/plain
-w 把结果打印在html的表格里
-x 表格的属性
-y tr行属性
-z td列属性
-C 设置cookie 例如Apach=1234
-H header行, 例如Accept-Encoding:gzip
-k 是否标示位HTTP Keep Alive
测试结果:
This is ApacheBench, Version 2.3 <$Revision: $>
Copyright Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient)
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Finished requests Server Software:
Server Hostname: localhost
Server Port: Document Path: /
Document Length: bytes Concurrency Level:
Time taken for tests: 0.323 seconds
Complete requests:
Failed requests:
Total transferred: bytes
HTML transferred: bytes
Requests per second: 3097.37 [#/sec] (mean)
Time per request: 3.229 [ms] (mean)
Time per request: 0.323 [ms] (mean, across all concurrent requests)
Transfer rate: 347.85 [Kbytes/sec] received Connection Times (ms)
min mean[+/-sd] median max
Connect: 0.1
Processing: 2.2
Waiting: 2.2
Total: 2.2 Percentage of the requests served within a certain time (ms)
%
%
%
%
%
%
%
%
% (longest request)
最新文章
- could not initialize proxy - no Session
- PHP对象转数组||PHP数组转对象
- c++模板库(简介)
- demo04calc
- 2016 - 1 - 20 runloop学习(2)
- javascript调试
- stm32之中断系统
- C++STL之set容器及stream类
- HDU 1828 Picture(长方形的周长和)
- jquery源码分析之一前言篇
- 使用Unity NGUI-InputField组件输入时发现显示为白色就是看不到字体
- 05解决flask循环引用的问题
- Dio添加Cookie
- Jquery Pagination分页插件使用
- JAVA-集合类型List(ArrayList、LinkedList)常用操作例子(基础必备)
- Docker入门 - 006 Docker 多种数据库的安装
- Array数组内函数
- [UE4]自定义服务器Service
- linux 时间相关的一些总结
- [leetcode]Search a 2D Matrix @ Python
热门文章
- iOS开发融云即时通讯集成详细步骤
- 选择排序(java版)
- C语言---文件
- 使用OLE DB读写Excel
- android多种布局的列表实现
- GridControl控件的数据显示的样式控制(转)
- 问题解决——cout 输出 CString
- 【linux环境下】RabbitMq的安装和监控插件安装
- web.xml文件报错:The processing instruction target matching ";[xX][mM][lL]"; is not allowed.
- 关于字符编码:为什么在ASCII字符集中小写字母比大写字母大32