使用Apache ab进行http性能测试

作者:张三的美丽家园 时间:2023-07-07 11:42:01 

Mac自带了Apache环境

打开“终端(terminal)”,输入 sudo apachectl -v,(可能需要输入机器秘密)。如下显示Apache的版本

使用Apache ab进行http性能测试

接着输入 sudo apachectl start,这样Apache就启动了。打开Safari浏览器地址栏输入 “http://localhost”,可以看到内容为“It works!”的页面。其位于“/Library(资源库)/WebServer/Documents/”下,这就是Apache的默认根目录。

Apache的安装目录在:/etc/apache2/,etc默认是隐藏的。有三种方式查看:

1、dock下右键Finder,选择"前往文件夹",输入"/etc"
2、在finder下----》前往---》前往文件夹,然后输入/etc
3、可以在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: 1663405 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:  
Server Hostname:  localhost
Server Port:   3000

Document Path:   /
Document Length:  14 bytes

Concurrency Level:  10
Time taken for tests: 0.323 seconds
Complete requests:  1000
Failed requests:  0
Total transferred:  115000 bytes
HTML transferred:  14000 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 0 0.1  0  1
Processing:  1 3 2.2  2  16
Waiting:  1 3 2.2  2  16
Total:   1 3 2.2  2  16

Percentage of the requests served within a certain time (ms)
50%  2
66%  3
75%  3
80%  4
90%  5
95%  7
98%  13
99%  15
100%  16 (longest request)

来源:https://www.cnblogs.com/greatluoluo/p/5725978.html

标签:Apache,ab,性能测试
0
投稿

猜你喜欢

  • 自已建站思路回顾与反思 关于建站和盈利

    2009-02-05 09:30:00
  • Exchange服务器的备份与保护

    2010-03-01 18:54:00
  • 英特尔将涉足视频游戏机 挑战索尼微软任天堂

    2009-10-12 08:24:00
  • 构建反病毒反垃圾邮件系统(七)

    2007-10-10 14:39:00
  • AdSense又一新功能 - 广告查看中心

    2007-12-19 12:49:00
  • 闲谈 Web 图片服务器

    2008-03-20 13:43:00
  • centos7修改系统语言为简体中文的实现

    2022-08-18 09:48:40
  • 酷我音乐盒炫酷首推李宇春专版皮肤

    2009-11-07 16:19:00
  • WordPress博客转换到独立域名Blogger的方法

    2010-03-23 09:19:00
  • phpwindV6.3关于改名后可以重复投票问题

    2009-02-20 16:03:00
  • Linux实现文件内容去重及求交并差集

    2023-11-02 18:55:09
  • VM12中CentOS7以NAT的方式连接网络的方法

    2023-07-29 13:10:13
  • 百度优化VS谷歌优化 浅谈针对优化差异性

    2009-03-13 15:16:00
  • PHPwind整合最土系统用户同步登录

    2010-12-14 14:46:00
  • IIS部署asp.net报404错误的解决方法

    2023-11-03 08:04:53
  • SYN攻击原理与防范技术

    2009-09-20 20:17:00
  • 站长购买美国主机选择10个基本参考 别给空间商忽悠

    2010-03-25 14:21:00
  • SiteServer CMS 第一届模板大赛正式启动

    2010-01-16 11:45:00
  • 如何让百度快速收录你设计的网站

    2007-09-21 14:12:00
  • 创业邦采用康盛创想UCHome推出社交网络平台创业驿站

    2009-10-29 15:28:00
  • asp之家 网站运营 m.aspxhome.com