开发者

Apache/PHP test server throttle by request

开发者 https://www.devze.com 2023-01-31 03:57 出处:网络
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.For the most part it\'s pretty sweet, but I\'ve run into a

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. 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 c开发者_C百科onnection doesn't really exist as a physical connection, so it will run as fast as the computer hardware will allow. 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. 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. 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.

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? 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? 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.

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.


What you're asking for is called Traffic Shaping.

Lighttpd (an alternative to Apache) supports this natively

For Apache, there are a few ways of doing it.

  • mod_bandwidth - A 3pd module (that hasn't been updated recently) which appears to do the same thing.
  • mod_bwshare - 3pd module designed to combat DOS attacks, but may be helpful.

Here's a ServerFault Question that may be relevant...


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. That's what I've been using today for testing my APC code and it all seems to be working fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消