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. pku 2284 That Nice Euler Circuit

    题意: 给你n个点第n个点保证与第0个点相交,然后求这n个点组成的图形可以把整个平面分成几个面 思路: 这里的解题关键是知道关于多面体的欧拉定理 多面体: 设v为顶点数,e为棱数,f是面数,则v-e+ ...

  2. codeforces 354 div2 C Vasya and String 前缀和

    C. Vasya and String time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. python 匹配指定后缀的文件名

    import glob x=glob.glob('*.py') print(x)

  4. python stat获取文件信息

    import os statinfo = os.stat('qqq.txt') print(statinfo,"\n") print(statinfo.st_mode) 输出 os ...

  5. Mac adb 安装

    一.下载Android studio https://developer.android.google.cn/studio/ 二.安装 首先移动 弹出下面弹框,直接点击OK 提示无法访问Android ...

  6. USB.资料

    1.百度搜索 “usb java” 1.1.基于usb4java实现的java下的usb通信 - tomi_mint - 博客园.html(https://www.cnblogs.com/sowhat ...

  7. Java回顾之集合

    在这篇文章里,我们关注Java中的集合(Collection).集合是编程语言中基础的一部分,Java自JDK早期,就引入了Java Collection Framework.设计JCF的那个人,后来 ...

  8. Python str 与 bytes 类型 之间的转换

    bytes:字节数组,通常用它可以描述 “一个字符串”,只不过该字符串是  “bytes类型”,所以容易与str类型混淆,他们二者之间的转换: https://blog.csdn.net/lanchu ...

  9. Leetcode 18

    class Solution { public: vector<vector<int>> fourSum(vector<int>& nums, int ta ...

  10. MyBatis Generator去掉生成的注解

    是不是很讨厌mybatis Generator帮我们生成代码的时候在Mapper和mapper.xml文件中生成的一大堆注解?今天在看MyBatis Generator代码的时候发现,原来mybati ...