apache ab压力测试报错
今天用apache 自帶的ab工具測(cè)試,當(dāng)并發(fā)量達(dá)到1000多的時(shí)候報(bào)錯(cuò)如下:
[root@aa~]# This is ApacheBench, Version 2.3 <Revision:655654>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.1.176 (be patient)
Completed 300 requests
Completed 600 requests
Completed 900 requests
apr_socket_recv: Connection reset by peer (104)
Total of 1085 requests completed
查看應(yīng)用服務(wù)器和數(shù)據(jù)庫均未報(bào)錯(cuò),連接被重置,bingyi了以下,apr_socket_recv這個(gè)是操作系統(tǒng)內(nèi)核的一個(gè)參數(shù),在高并發(fā)的情況下,內(nèi)核會(huì)認(rèn)為系統(tǒng)受到了SYN flood攻擊,會(huì)發(fā)送cookies(possible SYN flooding on port 80. Sending cookies),這樣會(huì)減慢影響請(qǐng)求的速度,所以在應(yīng)用服務(wù)武器上設(shè)置下這個(gè)參數(shù)為0禁用系統(tǒng)保護(hù)就可以進(jìn)行大并發(fā)測(cè)試了:
# vim /etc/sysctl.conf net.ipv4.tcp_syncookies = 0 # sysctl -p然后就可以超過1000個(gè)并發(fā)測(cè)試了。
另附其他系統(tǒng)內(nèi)核參數(shù)說明:
net.ipv4.tcp_syncookies = 0 #此參數(shù)是為了防止洪水攻擊的,但對(duì)于大并發(fā)系統(tǒng),要禁用此設(shè)置net.ipv4.tcp_max_syn_backlog #參數(shù)決定了SYN_RECV狀態(tài)隊(duì)列的數(shù)量,一般默認(rèn)值為512或者1024,即超過這個(gè)數(shù)量,系統(tǒng)將不再接受新的TCP連接請(qǐng)求,一定程度上可以防止系統(tǒng)資源耗盡。可根據(jù)情況增加該值以接受更多的連接請(qǐng)求。net.ipv4.tcp_tw_recycle #參數(shù)決定是否加速TIME_WAIT的sockets的回收,默認(rèn)為0。net.ipv4.tcp_tw_reuse #參數(shù)決定是否可將TIME_WAIT狀態(tài)的sockets用于新的TCP連接,默認(rèn)為0。net.ipv4.tcp_max_tw_buckets #參數(shù)決定TIME_WAIT狀態(tài)的sockets總數(shù)量,可根據(jù)連接數(shù)和系統(tǒng)資源需要進(jìn)行設(shè)置。另外ab中自帶參數(shù)
-r Don’t exit on socket receive errors.
可以避免并發(fā)過大出現(xiàn)錯(cuò)誤,從而實(shí)現(xiàn)大并發(fā)測(cè)試,建議使用此方法。
ab 的各種參數(shù)
-n requests Number of requests to perform-c concurrency Number of multiple requests to make at a time-t timelimit Seconds to max. to spend on benchmarkingThis implies -n 50000-s timeout Seconds to max. wait for each responseDefault is 30 seconds-b windowsize Size of TCP send/receive buffer, in bytes-B address Address to bind to when making outgoing connections-p postfile File containing data to POST. Remember also to set -T-u putfile File containing data to PUT. Remember also to set -T-T content-type Content-type header to use for POST/PUT data, eg.'application/x-www-form-urlencoded'Default is 'text/plain'-v verbosity How much troubleshooting info to print-w Print out results in HTML tables-i Use HEAD instead of GET-x attributes String to insert as table attributes-y attributes String to insert as tr attributes-z attributes String to insert as td or th attributes-C attribute Add cookie, eg. 'Apache=1234'. (repeatable)-H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'Inserted after all normal header lines. (repeatable)-A attribute Add Basic WWW Authentication, the attributesare a colon separated username and password.-P attribute Add Basic Proxy Authentication, the attributesare a colon separated username and password.-X proxy:port Proxyserver and port number to use-V Print version number and exit-k Use HTTP KeepAlive feature-d Do not show percentiles served table.-S Do not show confidence estimators and warnings.-q Do not show progress when doing more than 150 requests-l Accept variable document length (use this for dynamic pages)-g filename Output collected data to gnuplot format file.-e filename Output CSV file with percentages served-r Don't exit on socket receive errors.-h Display usage information (this message)-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)-f protocol Specify SSL/TLS protocol(SSL3, TLS1, TLS1.1, TLS1.2 or ALL) - n請(qǐng)求執(zhí)行的請(qǐng)求數(shù) - c多次請(qǐng)求的并發(fā)數(shù) - t限時(shí)秒到最大值。花在基準(zhǔn)測(cè)試 這意味著- n 50000 - s超時(shí)秒到最大值。等待每個(gè)響應(yīng) 默認(rèn)值為30秒 - b窗口大小的TCP發(fā)送/接收緩沖區(qū),以字節(jié)為單位 - b地址地址在發(fā)送連接時(shí)綁定 -p postfile文件,包含要發(fā)布的數(shù)據(jù)。記住也要設(shè)置- t -u putfile文件中包含的數(shù)據(jù)。記住也要設(shè)置- t - t內(nèi)容類型的內(nèi)容類型標(biāo)題用于POST / PUT數(shù)據(jù)。 “應(yīng)用程序/ x-www -表單- urlen編碼” 默認(rèn)是“text / plain” -v verbosity有多少故障排除信息打印 - w打印結(jié)果在HTML表 我用HEAD代替GET - x屬性字符串作為表屬性插入 - y屬性字符串作為tr屬性插入 - z屬性字符串作為td或th屬性插入 - c屬性添加cookie。Apache = 1234。(重復(fù)) - h屬性添加任意標(biāo)題行。“接受編碼:gzip” 插入所有正常的標(biāo)題行。(重復(fù)) 屬性添加基本的WWW認(rèn)證,屬性 是一個(gè)冒號(hào)分隔的用戶名和密碼。 - p屬性添加基本代理身份驗(yàn)證,屬性 是一個(gè)冒號(hào)分隔的用戶名和密碼。 - x代理:使用端口Proxyserver和端口號(hào) - v打印版本號(hào),退出 - k使用HTTP KeepAlive功能 - d不顯示百分比表。 - s不顯示置信估計(jì)者和警告。 當(dāng)超過150個(gè)請(qǐng)求時(shí),q沒有顯示進(jìn)展 - l接受可變文檔長(zhǎng)度(用于動(dòng)態(tài)頁面) - g文件名輸出數(shù)據(jù)到gnuplot格式文件。 - e文件名輸出CSV文件的百分比 - r不退出套接字接收錯(cuò)誤。 - h顯示使用信息(此消息) - z ciphersuite指定SSL / TLS密碼套件(見openssl密碼) - f協(xié)議指定SSL / TLS協(xié)議 (SSL3,TLS1,TLS1.1,TLS1.2或全部)總結(jié)
以上是生活随笔為你收集整理的apache ab压力测试报错的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 三国佚事——巴蜀之危【递推】
- 下一篇: Shell Pyramid【数学+二分】