我正在尝试在Widows Azure上扩展网站.到目前为止,我已经测试了Wordpress,Ghost(博客)和纯HTML网站,它们都是一样的:如果我扩展它们(添加实例),它们就不会更快.我确信我必须做错事......这就是我所做的:
我创建了一个新的共享网站,上面有一个简单的HTML Bootstrap模板.http://demobootstrapsite.azurewebsites.net/
然后我在托管的裸机服务器上安装了来自Apache Project的 ab.exe (4个核心,12 GB RAM,100 MBit)
我跑了两次测试.第一次使用单个共享实例,第二次使用此命令使用两个共享实例:
ab.exe -n 10000 -c 100 http://demobootstrapsite.azurewebsites.net/
这意味着ab.exe将使用100个并行线程创建10000个请求.
我希望两个共享实例的测试响应时间明显低于只有一个共享实例的响应时间.但是每个请求的平均时间甚至从一个共享实例的1452.519 ms增加到两个共享实例的1460.631 ms.后来我甚至在8个共享实例上运行了该站点,完全没有任何效果.我的第一个想法是,共享实例可能是问题所在.所以我将网站放在标准VM上并再次运行测试.但问题仍然存在.此外,添加更多实例并不会使网站更快(甚至更慢).
后来我和Scott Hanselman和Stefan Schackow一起讨论了一个视频,他们已经解释了Azure Scaling功能.Stefan说Azure有一种"粘性负载均衡",它会将客户端始终重定向到同一个实例/ VM,以避免与状态良好的应用程序出现兼容性问题.所以我检查了WebServer日志,我发现每个实例的日志文件大小相同.通常这意味着在测试期间使用了每个实例.
PS:在测试运行期间,我已经从本地计算机(来自与服务器不同的网络)检查了网站的响应时间,响应时间约为1.5秒.
以下是测试结果:
###################################### 1 instance result ###################################### PS C:\abtest> .\ab.exe -n 10000 -c 100 http://demobootstrapsite.azurewebsites.net/ This is ApacheBench, Version 2.3 <$Revision: 1528965 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking demobootstrapsite.azurewebsites.net (be patient) Finished 10000 requests Server Software: Microsoft-IIS/8.0 Server Hostname: demobootstrapsite.azurewebsites.net Server Port: 80 Document Path: / Document Length: 16396 bytes Concurrency Level: 100 Time taken for tests: 145.252 seconds Complete requests: 10000 Failed requests: 0 Total transferred: 168800000 bytes HTML transferred: 163960000 bytes Requests per second: 68.85 [#/sec] (mean) Time per request: 1452.519 [ms] (mean) Time per request: 14.525 [ms] (mean, across all concurrent requests) Transfer rate: 1134.88 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 14 8.1 16 78 Processing: 47 1430 93.9 1435 1622 Waiting: 16 705 399.3 702 1544 Total: 62 1445 94.1 1451 1638 Percentage of the requests served within a certain time (ms) 50% 1451 66% 1466 75% 1482 80% 1498 90% 1513 95% 1529 98% 1544 99% 1560 100% 1638 (longest request) ###################################### 2 instances result ###################################### PS C:\abtest> .\ab.exe -n 10000 -c 100 http://demobootstrapsite.azurewebsites.net/ This is ApacheBench, Version 2.3 <$Revision: 1528965 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking demobootstrapsite.azurewebsites.net (be patient) Finished 10000 requests Server Software: Microsoft-IIS/8.0 Server Hostname: demobootstrapsite.azurewebsites.net Server Port: 80 Document Path: / Document Length: 16396 bytes Concurrency Level: 100 Time taken for tests: 146.063 seconds Complete requests: 10000 Failed requests: 0 Total transferred: 168800046 bytes HTML transferred: 163960000 bytes Requests per second: 68.46 [#/sec] (mean) Time per request: 1460.631 [ms] (mean) Time per request: 14.606 [ms] (mean, across all concurrent requests) Transfer rate: 1128.58 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 14 8.1 16 78 Processing: 31 1439 92.8 1451 1607 Waiting: 16 712 402.5 702 1529 Total: 47 1453 92.9 1466 1622 Percentage of the requests served within a certain time (ms) 50% 1466 66% 1482 75% 1482 80% 1498 90% 1513 95% 1529 98% 1544 99% 1560 100% 1622 (longest request)
Andrew.. 5
在资源方面"扩展"网站增加了接受更多请求的容量,并且不会增加单个容量实例在未过载时可以执行的速度.
例如; 假设一个小型虚拟机每秒可以接受100个请求,在1000毫秒处理每个请求(如果它是每秒101个请求,每个请求将开始减慢到1500毫秒),那么扩展到更小的虚拟机将不会提高速度在一个请求可以处理的情况下,它只是让我们在每个1000毫秒内接受每秒200个请求(因为现在这两个机器都没有超载).
对于按请求的性能; 代码本身(以及Azure VM的CPU性能)将影响单个请求的执行速度.
在资源方面"扩展"网站增加了接受更多请求的容量,并且不会增加单个容量实例在未过载时可以执行的速度.
例如; 假设一个小型虚拟机每秒可以接受100个请求,在1000毫秒处理每个请求(如果它是每秒101个请求,每个请求将开始减慢到1500毫秒),那么扩展到更小的虚拟机将不会提高速度在一个请求可以处理的情况下,它只是让我们在每个1000毫秒内接受每秒200个请求(因为现在这两个机器都没有超载).
对于按请求的性能; 代码本身(以及Azure VM的CPU性能)将影响单个请求的执行速度.