简体   繁体   English

Nginx反向代理背后的Apache / PHP速度慢于预期

[英]Apache/PHP behind Nginx Reverse Proxy slower than expected

I'm not certain what I'm missing, or overlooking. 我不确定我所缺少或忽略的内容。 Or maybe I'm just not thinking about something correctly. 也许我只是没有正确考虑某件事。

I am testing Apache/PHP behind an Nginx reverse proxy, (Nginx is performing GZIP, KeepAlive, and SSL). 我正在Nginx反向代理后面测试Apache / PHP(Nginx正在执行GZIP,KeepAlive和SSL)。

Testing using Apache Bench from another server within the same local network can perform 500 connections (100 concurrent) in 0.349 seconds. 使用Apache Bench从同一局域网中的另一台服务器进行测试,可以在0.349秒内执行500个连接(并发100个连接)。 However, when I connect using a browser, the timeline for the page load shows 2 seconds of waiting for a server response. 但是,当我使用浏览器进行连接时,页面加载的时间轴显示等待服务器响应的时间为2秒。

The only thing I can think is that the proxy for the network is playing a role (the server is outside the proxy, so requests from my browser pass through the proxy). 我唯一能想到的是网络代理正在发挥作用(服务器在代理外部,因此来自我的浏览器的请求将通过代理)。 I'm getting 'Vary-Accept' header responses for encoding, which makes me think that might be the issue. 我正在获取“ Vary-Accept”标头响应进行编码,这让我认为这可能是问题所在。 When I use WBOX from my computer, however, it returns 2-30ms response times. 但是,当我从计算机上使用WBOX时,它将返回2-30ms的响应时间。

Any thoughts? 有什么想法吗?

So, I resolved the issue and hopefully this will help others. 因此,我解决了这个问题,希望对您有所帮助。 I had caching disabled correctly on Nginx, and was passing through a no-cache header, however I had SendFile enabled on Nginx, and which appears to have been causing it to still cache files regardless of my settings. 我已在Nginx上正确禁用了缓存,并且正在通过一个不缓存的标头,但是我在Nginx上启用了SendFile,这似乎导致它仍然缓存文件,无论我如何设置。 I disabled this feature, and cleared the cache on the browser, and it's been making fast requests ever since. 我禁用了此功能,并清除了浏览器上的缓存,此后一直在快速发出请求。

I'm not certain if SendFile writes to disk in the same way that cache might, and that was causing the issue, but disabling certainly solved a ton of issues. 我不确定SendFile是否以与缓存可能的方式相同的方式写入磁盘,这是造成此问题的原因,但是禁用确实可以解决很多问题。

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

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