1.安裝apache ab插件
apt-get install apache2-utils
2.更改ipv4內核參數
nano /proc/sys/net/ipv4/tcp_tw_recycle 值=1
nano /proc/sys/net/ipv4/tcp_tw_reuse 值=1
3.壓力測試
ab -c100 -n300 -k 'http://127.0.0.1:1703/istore/store/news/information?limit=12&asyncTotalCount=1'
4.監聽sock變化
watch -n 1 'cat /proc/net/sockstat'
[root@vic html]# ab -c 10 -n 100 http://www.myvick.cn/index.php 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 www.myvick.cn (be patient).....done Server Software: nginx/1.13.6 #測試服務器的名字 Server Hostname: www.myvick.cn #請求的URL主機名 Server Port: 80 #web服務器監聽的端口 Document Path: /index.php #請求的URL中的根絕對路徑,通過該文件的后綴名,我們一般可以了解該請求的類型 Document Length: 799 bytes #HTTP響應數據的正文長度 Concurrency Level: 10 # 並發用戶數,這是我們設置的參數之一 Time taken for tests: 0.668 seconds #所有這些請求被處理完成所花費的總時間 單位秒 Complete requests: 100 # 總請求數量,這是我們設置的參數之一 Failed requests: 0 # 表示失敗的請求數量,這里的失敗是指請求在連接服務器、發送數據等環節發生異常,以及無響應后超時的情況 Write errors: 0 Total transferred: 96200 bytes #所有請求的響應數據長度總和。包括每個HTTP響應數據的頭信息和正文數據的長度 HTML transferred: 79900 bytes # 所有請求的響應數據中正文數據的總和,也就是減去了Total transferred中HTTP響應數據中的頭信息的長度 Requests per second: 149.71 [#/sec] (mean) #吞吐率,計算公式:Complete requests/Time taken for tests 總請求數/處理完成這些請求數所花費的時間 Time per request: 66.797 [ms] (mean) # 用戶平均請求等待時間,計算公式:Time token for tests/(Complete requests/Concurrency Level)。處理完成所有請求數所花費的時間/(總請求數/並發用戶數) Time per request: 6.680 [ms] (mean, across all concurrent requests) #服務器平均請求等待時間,計算公式:Time taken for tests/Complete requests,正好是吞吐率的倒數。也可以這么統計:Time per request/Concurrency Level Transfer rate: 140.64 [Kbytes/sec] received #表示這些請求在單位時間內從服務器獲取的數據長度,計算公式:Total trnasferred/ Time taken for tests,這個統計很好的說明服務器的處理能力達到極限時,其出口寬帶的需求量。 Connection Times (ms) min mean[+/-sd] median max Connect: 1 2 0.7 2 5 Processing: 2 26 81.3 3 615 Waiting: 1 26 81.3 3 615 Total: 3 28 81.3 6 618 Percentage of the requests served within a certain time (ms) 50% 6 66% 6 75% 7 80% 7 90% 10 95% 209 98% 209 99% 618 100% 618 (longest request) #Percentage of requests served within a certain time(ms)這部分數據用於描述每個請求處理時間的分布情況,比如以上測試,80%的請求處理時間都不超過7ms,這個處理時間是指前面的Time per request,即對於單個用戶而言,平均每個請求的處理時間
###############################################DZADSL2674733#########################################