Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to stress test a particular PHP script that forces a a very large file to download, but specifically when clients with slow connections are making the request. I also want to concurrently test how the rest of the site performs under such a load. I have FiOS so doing a few dozen concurrent connections doesn't really put the server under load for very long (we don't care about volume as we don't anticipate a lot of concurrent connections for this file, just a few dozen really slow ones) and I want to test it as if I'm on a slow connection of say 100kb/sec. Is there a way to limit how fast ApacheBenchmark connects to a site? Or is there another way to temporarily throttle my connection to this site? I'm running Mac OS X locally, and the server is a Windows box running Apache.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

One possibility would be to use the IPFW feature set of OS X. IPFW is the software firewall of OS X that happens to also support traffic shaping. Here's how to configure it (assuming a 1.2.3.4 as the web server IP address):

  1. Open the Terminal application to get a command line.
  2. Create the virtual network device
    sudo ipfw pipe 1 config bw 15Kbyte/s
  3. Create the two rules that will redirect traffic to/from the web server through the virtual device:
    sudo ipfw add 1 pipe 1 ip from 1.2.3.4 to any sudo ipfw add 2 pipe 1 ip from any to 1.2.3.4

Now all traffic between your OS X computer and the web server will be limited to 15KB/s (change this value as needed).

To remove the configuration to revert to unlimited bandwidth:
sudo ipfw delete 1
sudo ipfw delete 2
ipfw pipe delete 1

Caveat:
1. I am unsure if the configuration, once set, survives across a reboot.
2. This assumes your software firewall isn't already configured; if it is, then rules 1 and 2 may already exist and the commands here would cause errors.

Hope this helps.

share|improve this answer
    
This is the "dummynet" functionality, if you want more info on how to use ipfw on OSX or BSD for this purpose you can check out info.iet.unipi.it/~luigi/dummynet –  Ernest Mueller Aug 31 '10 at 2:44
    
Thanks guys, this seems like it will do what I want. –  Chrisbloom7 Aug 31 '10 at 13:28

I'm glad you're doing that; many people don't understand that their apps will behave fundamentally differently once they get out of the lab to the 'real Internet.'

The general category of what you're looking for is a WAN emulator. They sell hardware devices (and software) that do this from about $2k on up if you want to do it a lot and not just vary bandwidth, but latency, jitter, and other factors. Shunra and Linktropy are two good suppliers.

But there's a lot of software only solutions as well. Most of them run on Linux, but I imagine some might be coaxed to work on OSX. Wanem is a good free one. ns-2 is a free simulator, which is different and probably more complicated than what you want, you build out a fake network and it simulates that.

Or dummynet, but I'll add that to Urgoll's good answer.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.