Mac 使用ab命令进行压测

1.在Mac中配置Apache

①启动Apache,打开终端

 sudo apachectl -v

如下显示Apache的版本

sudo apachectl start

这样Apache就启动了。打开Safari浏览器地址栏输入 “http://localhost”,可以看到内容为“It works!”的页面

②设置虚拟端终机

打开Apache的配置文件

sudo vi /etc/apache2/httpd.conf

在httpd.conf中找到“#Include /private/etc/apache2/extra/httpd-vhosts.conf”,去掉前面的“#”,保存并退出,去掉这一行的#意思是从/extra/httpd-vhosts.conf这个文件导入虚拟主机配置。

#Include /private/etc/apache2/extra/httpd-vhosts.conf

然后重启Apache

sudo apachectl restart

运行如下命令:

sudo vi /etc/apache2/extra/httpd-vhosts.conf

就打开了配置虚拟主机文件httpd-vhost.conf,配置虚拟主机了。需要注意的是该文件默认开启了两个作为例子的虚拟主机:

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost> <VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>

需要增加如下配置:

<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents"
ServerName localhost
ErrorLog "/private/var/log/apache2/localhost-error_log"
CustomLog "/private/var/log/apache2/localhost-access_log" common
</VirtualHost> <VirtualHost *:80>
DocumentRoot "/Users/snandy/work"
ServerName mysites
ErrorLog "/private/var/log/apache2/sites-error_log"
CustomLog "/private/var/log/apache2/sites-access_log" common
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

保存并退出

:wq
sudo apachectl restart

2.配置完成之后进行压测

ab -n 4 -c 2 https://www.baidu.com/

-n后面的是请求数

-c后面的是并发数

①Requests per second 吞吐率

计算公式:总请求数/处理完成这些请求数所花费的时间,即

Request per second=Complete requests/Time taken for tests

②Concurrency Level 并发用户数

要注意区分这个概念和并发连接数之间的区别,一个用户可能同时会产生多个会话,也即连接数。在HTTP/1.1下,IE7支持两个并发连接,IE8支持6个并发连接,FireFox3支持4个并发连接,所以相应的,我们的并发用户数就得除以这个基数。

③Time per request 用户平均请求等待时间

计算公式:处理完成所有请求数所花费的时间/(总请求数/并发用户数),即:

Time per request=Time taken for tests/(Complete requests/Concurrency Level)

④Time per request:across all concurrent requests 服务器平均请求等待时间

计算公式:处理完成所有请求数所花费的时间/总请求数,即:

Time taken for/testsComplete requests

Mac 使用ab性能测试工具的更多相关文章

  1. 转 Mac 使用ab性能测试工具

    Mac 使用ab命令进行压测 1.在Mac中配置Apache ①启动Apache,打开终端 sudo apachectl -v 如下显示Apache的版本 sudo apachectl start 这 ...

  2. ab性能测试工具的使用

    一.什么是ab ab,即Apache Benchmark,是一种用于测试Apache超文本传输协议(HTTP)服务器的工具. ab命令会创建很多的并发访问线程,模拟多个访问者同时对某一URL地址进行访 ...

  3. Centos6.5安装Apache ab性能测试工具

    ab简洁: ab是apache自带的压力测试工具,ab是apachebench命令的缩写. ab不仅可以对apache服务器进行网站访问压力测试,也可以对或其它类型的服务器进行压力测试. ab是一个h ...

  4. ab性能测试工具

    Apache自带的压力测试工具——ab初体验 http://studiogang.blog.51cto.com/505887/386852 我们知道压力测试的软件确实很多,诸如微软的WAST,惠普的L ...

  5. 【Code Tools】AB性能测试工具(一)

    一.工具下载 yum -y install httpd-tools 二.AB工具使用 格式: ab [options] [http://]hostname[:port]/path 例如:ab -n - ...

  6. ab 性能测试工具的使用(Web并发测试)

    1.下载 http://pan.baidu.com/s/1hrlAbI0 2.命令介绍 参数的介绍 n在测试会话中所执行的请求个数.默认时,仅执行一个请求. -c一次产生的请求个数.默认是一次一个. ...

  7. 【Code Tools】AB性能测试工具(二)

    一.测试Get请求 1.每次并发请求10个,总共1000个请求 ab -n -c https://www.baidu.com/ 2.指定Header参数 通过-H来指定 ab -n -c -H 'Ac ...

  8. 烂泥:apache性能测试工具ab的应用

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 网站性能压力测试是服务器网站性能调优过程中必不可缺少的一环.只有让服务器处在高压情况下,才能真正体现出软件.硬件等各种设置不当所暴露出的问题. 性能测试 ...

  9. Linux环境下apache性能测试工具ab使用详解

    网站性能压力测试是服务器网站性能调优过程中必不可缺少的一环.只有让服务器处在高压情况下,才能真正体现出软件.硬件等各种设置不当所暴露出的问题. 性能测试工具目前最常见的有以下几种:ab.http_lo ...

随机推荐

  1. OpenDayLight Helium实验三 OpenDaylight二层转发机制实验 2

    鉴于在个人笔记本上虚拟机运行ODL实在太慢,把实验的场景搬到了实验室. 实验上:OpenDayLight Helium实验三 OpenDaylight二层转发机制实验 抓包实验 紧接着,在运行Mini ...

  2. python 返回系统名称,系统平台,系统版本

    import platform import os print(os.name) print(platform.system()) print(platform.release())

  3. Android多个Module统一配置相同jar或库的版本号

    Android Studio多个Module依赖相同的库时对版本号进行统一配置 在Android项目中,一个项目经常会依赖其他的一个甚至多个库文件,在这种依赖的时候最常见的一个错误就是 jar包版本不 ...

  4. bzoj2152: 聪聪可可 树分治

    sb树分治 /************************************************************** Problem: 2152 User: walfy Lang ...

  5. hdu3032sg打表找规律

    先打个表冷静一下 #include<map> #include<set> #include<cmath> #include<queue> #includ ...

  6. gradle ssh 插件

    org.hidetake.ssh Gradle SSH Plugin is a Gradle plugin which provides remote command execution and fi ...

  7. 微信支付 WeixinJSBridge is not defined 报错

    https://www.cnblogs.com/ottoman/p/7614419.html 我没有用到微信JS-SDK或者接口都正确返回预支付id都正确, 为什么会报这个错呢?答: 微信内置浏览器会 ...

  8. Git观察和比较

    log git log 时间是从下到上,从远到近   whatchanged git whatchanged 时间是从下到上,从远到近   diff --staged 比较工作区和缓存区之间的差异 g ...

  9. hdu 3699 10 福州 现场 J - A hard Aoshu Problem 暴力 难度:0

    Description Math Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. N ...

  10. 多线程pre

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...