系统城装机大师 - 固镇县祥瑞电脑科技销售部宣传站!

当前位置:首页 > 系统教程 > Linux教程 > 详细页面

使用Apache ab进行http性能测试

时间:2019-12-30来源:系统城作者:电脑系统城

Mac自带了Apache环境

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

接着输入 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

测试结果:


 
  1. This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
  2. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  3. Licensed to The Apache Software Foundation, http://www.apache.org/
  4.  
  5. Benchmarking localhost (be patient)
  6. Completed 100 requests
  7. Completed 200 requests
  8. Completed 300 requests
  9. Completed 400 requests
  10. Completed 500 requests
  11. Completed 600 requests
  12. Completed 700 requests
  13. Completed 800 requests
  14. Completed 900 requests
  15. Completed 1000 requests
  16. Finished 1000 requests
  17.  
  18.  
  19. Server Software:
  20. Server Hostname: localhost
  21. Server Port: 3000
  22.  
  23. Document Path: /
  24. Document Length: 14 bytes
  25.  
  26. Concurrency Level: 10
  27. Time taken for tests: 0.323 seconds
  28. Complete requests: 1000
  29. Failed requests: 0
  30. Total transferred: 115000 bytes
  31. HTML transferred: 14000 bytes
  32. Requests per second: 3097.37 [#/sec] (mean)
  33. Time per request: 3.229 [ms] (mean)
  34. Time per request: 0.323 [ms] (mean, across all concurrent requests)
  35. Transfer rate: 347.85 [Kbytes/sec] received
  36.  
  37. Connection Times (ms)
  38. min mean[+/-sd] median max
  39. Connect: 0 0 0.1 0 1
  40. Processing: 1 3 2.2 2 16
  41. Waiting: 1 3 2.2 2 16
  42. Total: 1 3 2.2 2 16
  43.  
  44. Percentage of the requests served within a certain time (ms)
  45. 50% 2
  46. 66% 3
  47. 75% 3
  48. 80% 4
  49. 90% 5
  50. 95% 7
  51. 98% 13
  52. 99% 15
  53. 100% 16 (longest request)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

分享到:

相关信息

  • linux定时关机设置教程

    当linux在运作时不能直接关闭电源容易将档案系统损毁,因此需要用shutdown以安全的方式关闭,那么这个操作该怎么实现呢?下面就为大家带来了详细教程。...

    2022-11-07

  • linux强制删除文件教程

    由于linux系统和我们常用的windows系统是不一样的,所以如果是初学者,可能会不知道linux怎么强制删除文件,其实我们只要打开终端,使用命令就可以删除了。...

    2022-11-03

系统教程栏目

栏目热门教程

人气教程排行

站长推荐

热门系统下载