1) 目的:
访问localhost:18066
对下边两个端口负载
localhost:18098
localhost:18099
2) 手段:
1.通过nginx
2.通过iis的ARR(Application Request Routing)
3) 使用IIS的ARR
步骤:
1.部署porxy站点端口18066,
用来做转发。
注意:
需要把对应的应用程序池的“idel time-out”设置为0。
需要把回收时间调成0.
2.部署两个实际提供服务的站点
端口分别是18099和18098,按正常需要的配置
3.安装ARR,
地址(https://www.iis.net/downloads/microsoft/application-request-routing)
4.设置Server Farms
如下图,增加server时需要指定端口。注意:假如是重复的地址需要使用windwo\system32\drivers\ect\hosts中增加映射来避免重复。
如:
127.0.0.1 site1host
127.0.0.1 site2host
5.配置指定porxy端口使用对应的Server Farms。
(假如不指定则iis上所有正在的监听端口都会使用Server Farms导致错误)
6.测试
访问http://localhost:18096/aaa.txt
配置了轮训的负载策略后就看到了两个服务器返回对应的内容了
4) 附录:
三种访问情况性能对比,使用工具 apache benchmark,
在同一服务器上使用iis的arr的性能跟直接访问站点接近
在同一服务器上同样的方式nginx(windows)的性能只有1/3左右
直接访问10898
,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 |
通过nginx访问18066
,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 |
通过iis的ARR访问18096
, 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 |