使用Apacheab怎么对http的性能进行测试-创新互联

使用Apache ab怎么对http的性能进行测试?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

创新互联公司,是成都地区的互联网解决方案提供商,用心服务为企业提供网站建设、成都app软件开发小程序设计、系统定制设计和微信代运营服务。经过数十载的沉淀与积累,沉淀的是技术和服务,让客户少走弯路,踏实做事,诚实做人,用情服务,致力做一个负责任、受尊敬的企业。对客户负责,就是对自己负责,对企业负责。

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)

关于使用Apache ab怎么对http的性能进行测试问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。

名称栏目:使用Apacheab怎么对http的性能进行测试-创新互联
转载注明:https://www.cdcxhl.com/article34/ehsse.html

成都网站建设公司_创新互联,为您提供动态网站品牌网站建设App开发做网站网站收录响应式网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

h5响应式网站建设