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. 基于std::string的字符串处理

    转自:http://zxdflyer.blog.163.com/blog/static/25664262201322510217495/ C++标准模板库std使用广泛.该库中处理字符串的对象为std ...

  2. PhpStorm提高效率的使用方法及设置(快捷键)

    原文链接:https://my.oschina.net/chunto/blog/262954 快捷键: CTRL + D  复制当前行到下一行 或 复制选中内容到选中内容之后 CTRL + Y  删除 ...

  3. struts1和struts2比较

  4. python 字典添加元素

    d = {:, :} print(d) d.update({:}) print(d)

  5. 在 if 条件句中使用向量

    上述例子的函数中,都只输入了单一值.如果我们提供一个向量,那么这个函数将产生警告,这是因为 if 语句不能与多值向量共存.check_ _positive(c(1,-1,0))## Warning i ...

  6. 去掉Firefox的标题栏

    Linux Mint里,火狐的标题栏很不美观,不过火狐可是出名的的“可定制”,Hide Caption扩展拖拖地满足你的要求,简直不能再好! 献上链接: https://addons.mozilla. ...

  7. Psping 实例

    PsPing v2.1 https://docs.microsoft.com/zh-cn/sysinternals/downloads/psping 2016/06/29 4 分钟阅读时长 By Ma ...

  8. ansible常用套路(一)

    一.SSH互信 1 配置/etc/ansible/hosts 文件 [zabbix_agent] 172.26.4.203 172.26.4.204 172.26.4.205 [zabbix_agen ...

  9. CORS请求

    一.简介 CORS(跨域资源共享 Cross-origin resource sharing)是实现跨域的一种常用方式.实现CORS通信的关键是服务器.只要服务器实现了CORS接口,就可以跨源通信 二 ...

  10. 彻底明白IP地址——计算相关地址

    知道ip地址和子网掩码后可以算出: 1. 网络地址 2. 广播地址 3. 地址范围 4. 本网有几台主机 例1:下面例子IP地址为192·168·100·5 子网掩码是255·255·255·0.算出 ...