下載了 Nginx For Win32 的官方版本 nginx 0.7.53
進行了試用以及壓力測試。
安裝使用方式很簡單,直接貼官方的方式:
Win32 Binaries
As of 0.7.52, Nginx is now available as an official Windows binary.
Installation:
cd c:\
unzip nginx-0.7.52.zip
ren nginx-0.7.52 nginx
cd nginx
start nginx
Control:
nginx -s [ stop | quit | reopen | reload ]
For problems look in c:\nginx\logs\error.log or in EventLog.
但要說明一下的,之前有第三方編譯的 Nginx For Windows 版本,是可以載入到 Windows 服務中啟動並執行。但在這個官方版本下該方法行不通。所以建議暫時手動啟動,或者建立一個計劃任務開機啟動。
然後迫不及待進行壓力測試。我們使用的工具是 Apache 的 ab , 測試的是純靜態頁面。就是 Nginx 一裝好後預設的 :
Welcome to nginx!
測試命令:./ab -c 100 -n 10000 http://192.168.3.50:8888/
作業系統:Windows server 2003 R2
硬體設定:Xeon 2.8G X2 1G RAM
測試結果:
Server Software: nginx/0.7.53
Server Hostname: 192.168.3.50
Server Port: 8888
Document Path: /
Document Length: 151 bytes
Concurrency Level: 100
Time taken for tests: 107.329 seconds
Complete requests: 10000 (100%處理請求,沒有丟失)
Failed requests: 0
Write errors: 0
Total transferred: 3620000 bytes
HTML transferred: 1510000 bytes
Requests per second: 93.17 [#/sec] (mean) 每秒處理請求 93.17 個
Time per request: 1073.293 [ms] (mean)
Time per request: 10.733 [ms] (mean, across all concurrent requests)
Transfer rate: 32.94 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 13 44.3 2 550
Processing: 180 1059 350.5 1065 2665
Waiting: 178 1053 352.3 1058 2664
Total: 194 1071 351.9 1074 2668
Percentage of the requests served within a certain time (ms)
50% 1074
66% 1162
75% 1215
80% 1288
90% 1547
95% 1694
98% 1853
99% 1946
100% 2668 (longest request)
################
由測試結果所得,Nginx for windows 100 個線程每秒只能處理 93 個請求。
如果再啟動多一個 ab 來壓,加起來就有200個線程,ab結果相當。各端每秒處理93個請求。
但如果你再啟動第三ab 進行 100 個線程壓力,進行中的2個ab 其中一個就會被服務端拒絕。
來回嘗試修改Nginx的worker_processes 參數無果,修改了 Win2003 的並發線程也無果….難道 Nginx 在Windows下就只能有這麼點能耐??回頭要再詳細找找原因。
另外還有一個問題,當壓力測試完畢了,在 windows 中查看進程會發現 Nginx 還佔著 2~30 的cpu。
在命令列下 Nginx -s stop 也無法停止。必須 結束進程…..
################
初步嘗試就這幾點,希望是我個別的問題,有機會的朋友也不妨試試。
配置 PD930 CPU,2G 記憶體,測試結果如下:
C:\>ab -n 10000 -c 100 http://192.168.1.8/
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.8 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: nginx/0.7.52
Server Hostname: 192.168.1.8
Server Port: 80
Document Path: /
Document Length: 151 bytes
Concurrency Level: 100
Time taken for tests: 5.109 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 3620000 bytes
HTML transferred: 1510000 bytes
Requests per second: 1957.19 [#/sec] (mean)
Time per request: 51.094 [ms] (mean)
Time per request: 0.511 [ms] (mean, across all concurrent requests)
Transfer rate: 691.90 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.4 0 16
Processing: 16 50 13.3 47 78
Waiting: 0 34 14.4 31 78
Total: 16 51 13.3 47 78
Percentage of the requests served within a certain time (ms)
50% 47
66% 63
75% 63
80% 63
90% 63
95% 63
98% 63
99% 78
100% 78 (longest request)