使用Apache ab進(jìn)行http性能測(cè)試
Mac自帶了Apache環(huán)境
打開(kāi)“終端(terminal)”,輸入 sudo apachectl -v,(可能需要輸入機(jī)器秘密)。如下顯示Apache的版本

接著輸入 sudo apachectl start,這樣Apache就啟動(dòng)了。打開(kāi)Safari瀏覽器地址欄輸入 “http://localhost”,可以看到內(nèi)容為“It works!”的頁(yè)面。其位于“/Library(資源庫(kù))/WebServer/Documents/”下,這就是Apache的默認(rèn)根目錄。
Apache的安裝目錄在:/etc/apache2/,etc默認(rèn)是隱藏的。有三種方式查看:
1、dock下右鍵Finder,選擇"前往文件夾",輸入"/etc"
2、在finder下----》前往---》前往文件夾,然后輸入/etc
3、可以在terminal 輸入 "open /etc"
windows可以去http://httpd.apache.org/download.cgi下載,或者從命令行安裝
1. 安裝apache
sudo port install apache2
啟動(dòng)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/ 最后這個(gè)斜杠不能少
這個(gè)ab -n1000 -c10 http://localhost:3000/命令,在window系統(tǒng)下,需要先用cd命令定位到你的apache安裝目錄的bin文件夾。。。
ab的參數(shù)說(shuō)明
-n 需要執(zhí)行的請(qǐng)求次數(shù)
-c 并發(fā)的數(shù)量
-t 等待返回的最長(zhǎng)時(shí)間
-b TCP收發(fā)緩沖區(qū)的大小,單位(byte)
-p 使用post (同時(shí)需要定義-T參數(shù))
-u 使用put (同時(shí)需要定義-T參數(shù))
-T content-type, 例如application/x-www-form-urlencoded, 默認(rèn)為text/plain
-w 把結(jié)果打印在html的表格里
-x 表格的屬性
-y tr行屬性
-z td列屬性
-C 設(shè)置cookie 例如Apach=1234
-H header行, 例如Accept-Encoding:gzip
-k 是否標(biāo)示位HTTP Keep Alive
測(cè)試結(jié)果:
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)
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
linux負(fù)載均衡總結(jié)性說(shuō)明 四層負(fù)載和七層負(fù)載有什么區(qū)別
這篇文章主要為大家詳細(xì)介紹了linux負(fù)載均衡的相關(guān)資料,什么是負(fù)載均衡?四層負(fù)載和七層負(fù)載有什么區(qū)別?具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04
CentOS Linux系統(tǒng)搭建Android開(kāi)發(fā)環(huán)境詳細(xì)介紹
這篇文章主要介紹了CentOS Linux系統(tǒng)搭建Android開(kāi)發(fā)環(huán)境詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下2016-11-11
systemd添加自定義系統(tǒng)服務(wù)設(shè)置自定義開(kāi)機(jī)啟動(dòng)的方法
下面小編就為大家?guī)?lái)一篇systemd添加自定義系統(tǒng)服務(wù)設(shè)置自定義開(kāi)機(jī)啟動(dòng)的方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-12-12
使用 Apache Superset 可視化 ClickHouse 數(shù)據(jù)的兩種方法
Apache Superset是一個(gè)強(qiáng)大的BI工具,它提供了查看和探索數(shù)據(jù)的方法。它在 ClickHouse 用戶(hù)中也越來(lái)越受歡迎。今天將介紹安裝 Superset 的 2 種方法,通過(guò)示例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧2021-06-06
ubuntu14.04 使用中遇到的問(wèn)題及解決方法集錦
這篇文章主要介紹了ubuntu14.04 使用中遇到的問(wèn)題及解決方法集錦,需要的朋友可以參考下2014-10-10
增強(qiáng)Linux內(nèi)核中訪問(wèn)控制安全的方法
這篇文章主要給大家介紹了關(guān)于增強(qiáng)Linux內(nèi)核中訪問(wèn)控制安全的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-12-12
Apache Hive 通用調(diào)優(yōu)featch抓取機(jī)制 mr本地模式
這篇文章主要為大家介紹了Apache Hive 通用調(diào)優(yōu)featch抓取機(jī)制 mr本地模式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08

