windows下使用IIS的ARR實現站點的負載均衡 - CSDN博客 https://blog.csdn.net/zzy7075/article/details/73294713nginx
IIS的ARR實現站點的負載均衡 nginx 對比 apache
訪問localhost:18066windows
對下邊兩個端口負載服務器
localhost:18098app
localhost:18099負載均衡
1.經過nginxide
2.經過iis的ARR(Application Request Routing)工具
步驟:性能
用來作轉發。測試
注意:
須要把對應的應用程序池的「idel time-out」設置爲0。點擊對應的程序池,而後點擊高級配置,修改「閒置超時」(idel time out) 爲0。
須要把回收時間調成0。點擊對應的程序池,而後點擊右邊面板的「正在回收...」,按照下圖修改,去掉固定時間間隔。
端口分別是18099和18098,按正常須要的配置
地址(https://www.iis.net/learn/extensions/installing-application-request-routing-arr/install-application-request-routing-version-2)
這裏下載的是ARR2.0的包,因爲ARR3.0會把其餘內容分開來打包,因此提供2.0的總體包,3.0的你們能夠按需搜索使用
以下圖,增長server時須要指定端口,點擊 advanced settings展開更多選項,修改端口。注意:假如是重複的地址須要使用windwo\system32\drivers\ect\hosts中增長映射來避免重複。
如:
127.0.0.1 site1host
127.0.0.1 site2host
(假如不指定則iis上全部正在的監聽端口都會使用Server Farms致使錯誤)
點擊IIS下的「Server Farms」而後選中咱們新建立的farm,雙擊右邊中窗體中的「Routing Rules」配置路由規則
進入路由規則設置後,按照下圖選中第一個選項,使用URL Rewrite來實現請求的處理,而後點擊右邊的「URL Rewrite」地址重寫來配置具體規則
修改規則,因爲咱們這邊需求簡單,只須要把全部請求都轉發就能夠,因此使用正則「^(.*)」匹配全部內容,(須要轉發的內容匹配)
同時增長篩選條件(可以使用該Farms的規則),增長對端口({SERVER_PORT})的匹配,而後其餘默認就能夠
訪問http://localhost:18096/aaa.txt
配置了輪訓的負載策略後就看到了兩個服務器返回對應的內容了
三種訪問狀況性能對比,使用工具 apache benchmark,
在同一服務器上使用iis的arr的性能跟直接訪問站點接近
在同一服務器上一樣的方式nginx(windows)的性能只有1/3左右
,ab -n 10000 -c 3000 http://localhost:18098/天翼live工做.txt
Concurrency Level: 3000 Time taken for tests: 15.609 seconds Complete requests: 10000 Failed requests: 0 Total transferred: 12730000 bytes HTML transferred: 10290000 bytes Requests per second: 640.66 [#/sec] (mean) Time per request: 4682.668 [ms] (mean) Time per request: 1.561 [ms] (mean, across all concurrent requests) Transfer rate: 796.45 [Kbytes/sec] received |
,ab -n 10000 -c 3000 http://localhost:18066/aaa.txt
Concurrency Level: 3000 Time taken for tests: 38.987 seconds Complete requests: 10000 Failed requests: 0 Total transferred: 12685000 bytes HTML transferred: 10290000 bytes Requests per second: 256.49 [#/sec] (mean) Time per request: 11696.169 [ms] (mean) Time per request: 3.899 [ms] (mean, across all concurrent requests) Transfer rate: 317.74 [Kbytes/sec] received |
, ab -n 10000 -c 3000 http://localhost:18096/aaa.txt
Concurrency Level: 3000 Time taken for tests: 15.560 seconds Complete requests: 10000 Failed requests: 0 Total transferred: 12969758 bytes HTML transferred: 10290000 bytes Requests per second: 642.68 [#/sec] (mean) Time per request: 4667.967 [ms] (mean) Time per request: 1.556 [ms] (mean, across all concurrent requests) Transfer rate: 814.00 [Kbytes/sec] received |