简体   繁体   English

为什么Apache无法在Windows上以高并发率提供静态内容?

[英]Why is Apache unable to serve static content with high concurrency on Windows?

When testing Apache 2.4.16 on windows 7,8,2012 there is a severe limitation when serving static content. 在Windows 7,8,2012上测试Apache 2.4.16时,提供静态内容时存在严重限制。 Apache can't serve more than 700 concurrent requests for static content with Keep Alive OFF. 如果关闭“保持活动状态”,Apache不能为静态内容提供700个以上的并发请求。

When you attempt to do that one of two things will happen: 当您尝试执行此操作时,将发生以下两种情况之一:

  1. You will be able to server few thousand requests at first and then the remaining requests will take up to 10 seconds to complete. 首先,您将能够处理数千个请求,然后其余的请求最多需要10秒才能完成。 OR 要么
  2. You will receive a connection refused error 您将收到连接被拒绝的错误

Test method: 测试方法:

siege -b -c700 -t10s -v http://10.0.0.31/10k.txt    (10KB file)

OR 要么

ab -c 700 -n 40000 http://10.0.0.31/10k.txt 

However, when testing with Apache bench on the localhost (bypassing the network) Apache works fine and can serve 1000 concurrent requests for 10K static file. 但是,在本地主机上通过Apache Bench(绕过网络)进行测试时,Apache可以正常工作,并且可以为10K静态文件提供1000个并发请求。

Apache has ThreadsPerChild 7000 (increasing it to 14000 didn't make any difference) Apache拥有ThreadsPerChild 7000(将其增加到14000并没有什么不同)
MaxConnectionsPerChild 0 MaxConnectionsPerChild 0

Stack parameters: 堆栈参数:
MaxUserPort = 65534 MaxUserPort = 65534
TcpTimedWaitDelay = 30 TcpTimedWaitDelay = 30
Server has over 60,000 ephemeral ports available starting with port 5,000 to port 65534 服务器具有超过60,000个临时端口,从5,000端口到65534端口

  • My load testing server is Linux on a separate server and sends requests over the network to Apache Windows server over 10Gb/s network. 我的负载测试服务器是位于单独服务器上的Linux,并通过网络通过10Gb / s网络将请求发送到Apache Windows服务器。

  • There are no errors in the Apache log and nothing in the system logs. Apache日志中没有错误,系统日志中也没有错误。 The tasklist doesn't show anything unusual. 任务列表没有显示任何异常。

  • netstat shows few thousand (5,000) of open TCP connections and then Apache stops responding. netstat显示数千个(5,000)打开的TCP连接,然后Apache停止响应。 However when testing with lower concurrency of 300 then the OS can open 60,000 of TCP connections and Apache works fine. 但是,当使用较低的300并发进行测试时,操作系统可以打开60,000个TCP连接,Apache可以正常工作。

Potential Conclusions: At first I thought this is OS stack tuning problem but serving php file with the same concurrency works fine. 潜在结论:最初,我认为这是OS堆栈调整问题,但是以相同的并发度提供php文件可以很好地工作。

ab -c 700 -n 10000 http://10.0.0.31/phpinfo.php

Then I tried Nginx for windows on the same machine and Nginx served this without a problem. 然后,我尝试在同一台计算机上的Windows上使用Nginx,而Nginx做到了这一点没有问题。

ab -c 700 -n 10000 http://10.0.0.31/10k.txt

Nginx was able to serve much higher concurrency up to 2000 requests per second (static content) and the OS opened about 40,000 TCP connections. Nginx能够为每秒2000个请求(静态内容)提供更高的并发性,并且该操作系统打开了约40,000个TCP连接。

So this looks to me like a bug or a limitation in the way Apache communicates with the TCP/IP stack on windows. 因此,在我看来,这看起来像是Windows上Apache与TCP / IP堆栈进行通信的方式中的错误或限制。

When trying to duplicate this problem make sure Keep Alive is OFF and test it over the network (not on localhost). 尝试复制此问题时,请确保“保持活动”已关闭并通过网络(而不是在localhost上)对其进行测试。

Any answers or comments on this subject will be greatly appreciated. 对此问题的任何答案或评论将不胜感激。

Thanks to covener's suggestion here is the answer. 多亏了covener的建议,这里才是答案。

  1. Keep Alive was intentionally disabled to simulate a large number of users connecting from different IP addresses and spawning new TCP connections. 故意禁用Keep Alive来模拟大量用户从不同的IP地址进行连接并产生新的TCP连接。

  2. Setting AcceptFilter http to "none" together with turning off MultiViews improved the performance on static content and allowed Apache on windows to serve with concurrency of 2000 and beyond untill all ephemeral ports get exhausted. 将AcceptFilter http设置为“ none”并关闭MultiViews可以提高静态内容的性能,并允许Windows上的Apache以2000或更高的并发率提供服务,直到所有临时端口都用尽。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM