简体   繁体   English

Apache / PHP测试服务器按请求限制

[英]Apache/PHP test server throttle by request

I've recently set up a test server running in a virtual machine on my computer so I can do such things as interactive debugging with XDebug. 我最近在我的计算机上建立了一个在虚拟机中运行的测试服务器,所以我可以使用XDebug进行交互式调试。 For the most part it's pretty sweet, but I've run into a snag when running multiple requests to the server at once from the same client. 在大多数情况下,它非常甜蜜,但是当我从同一个客户端同时向服务器运行多个请求时,我遇到了麻烦。

The problem is that guest-host network connection doesn't really exist as a physical connection, so it will run as fast as the computer hardware will allow. 问题是,guest-host网络连接并不真正作为物理连接存在,因此它将以计算机硬件允许的速度运行。 This isn't usually a big issue, but I'm trying to implement APC file upload monitoring, and this requires an AJAX request to run in parallel to the file upload to monitor its performance. 这通常不是一个大问题,但我正在尝试实现APC文件上传监控,这需要一个AJAX请求与文件上传并行运行以监控其性能。 In the real world, the network would introduce lag and latency and suchlike, leaving enough unused bandwidth for the AjAX request to run in parallel with the file upload. 在现实世界中,网络将引入滞后和延迟等,留下足够的未使用带宽以使AjAX请求与文件上载并行运行。 However, in the test machine, the AJAX request can't fetch any data from the server until the upload is finished as there's absolutely no bandwidth left available to it. 但是,在测试机器中,AJAX请求无法从服务器获取任何数据,直到上传完成,因为它完全没有可用的带宽。

Is it possible to set up some kind of bandwidth management in the virtual machine (in Apache, PHP or some Linux utility) that could limit the bandwidth available per HTTP request? 是否可以在虚拟机中设置某种带宽管理(在Apache,PHP或某些Linux实用程序中),这可能会限制每个HTTP请求的可用带宽? For example so that each request is limited to 1mbps, but several requests can exist between the client and the server at the same time? 例如,每个请求限制为1mbps,但客户端和服务器之间可能同时存在多个请求? I'm hoping that if this can be done it will allow the AJAX request to fetch its data while the upload is progressing instead of being stalled until the upload actually completes. 我希望如果可以这样做,它将允许AJAX请求在上传进行时获取其数据,而不是在上传实际完成之前停止。

I tried a utility called IPRelay, but I don't seem able to get it to work, or at least not in a way that limits per request. 我尝试了一个名为IPRelay的实用程序,但我似乎无法使其工作,或者至少不能以限制每个请求的方式运行。

What you're asking for is called Traffic Shaping. 您要求的是流量整形。

Lighttpd (an alternative to Apache) supports this natively Lighttpd的(到Apache替代)支持该本地

For Apache, there are a few ways of doing it. 对于Apache,有几种方法可以做到这一点。

  • mod_bandwidth - A 3pd module (that hasn't been updated recently) which appears to do the same thing. mod_bandwidth - 一个3pd模块(最近没有更新)似乎做同样的事情。
  • mod_bwshare - 3pd module designed to combat DOS attacks, but may be helpful. mod_bwshare - 3pd模块旨在对抗DOS攻击,但可能会有所帮助。

Here's a ServerFault Question that may be relevant... 这是一个可能相关的ServerFault问题 ......

Thanks for the reply. 谢谢回复。 However, I found a handy little utility for Linux called iprelay that lets me throttle connections, it seems to let me have multiple connections open with each connection throttled to the specified limit. 但是,我找到了一个名为iprelay的Linux实用程序,它让我可以限制连接,它似乎让我打开了多个连接,每个连接被限制到指定的限制。 That's what I've been using today for testing my APC code and it all seems to be working fine. 这就是我今天用来测试我的APC代码的东西,它似乎都运行良好。

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

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