Rails Illustrated

Rails, Web Design and the User Experience

How to Simulate a Web Experience in Development

Certain things are just too fast in development mode. The bandwidth is essentially infinite and that is way to high to simulate the experience your users will have in production.

Slowing things down

I was looking for a way to test a file upload progress bar and found this great tip to throttle bandwidth on Mac OSX. Run the following commands if you serve your development application using Passenger:

sudo ipfw pipe 1 config bw 15KByte/s
sudo ipfw add 1 pipe 1 src-port 80
sudo ipfw add 1 pipe 1 dst-port 80

This will make all of the traffic to and from your local Apache server slow. Of course the port 80 can be changed to 3000 if you are using a Mongrel setup in development.

To go back to normal use:

 sudo ipfw delete 1

Make the wheel squeaky

If you are interacting with your site behind a slow connection it provides an easy way to see which parts of your application are too slow. These problems are sometimes more easily fixed early, such as when the design assets of the site are created. Note: this will slow down all of your web traffic. So if you are loading things like Prototype or jQuery from Google then this will also be slowed. Talk about a real simulation.

Testing a file upload progress bar

This technique works great when developing a progress bar as otherwise the upload tends to be complete before the progress bar gets a chance to do its thing.

Update: 37 signals has a blog post with a similar message: Why you should mix records on crap speakers



If you're looking for ipfw on ubuntu, you can find fwb_ipfw in the fwbuilder-bsd package.

Jonathan wrote on March 26 2009

Scratch that, I spoke too soon. fwb_ipfw only allows you to create BSD based ipfw firewall rules inside the fwbuilder application.

The truth bandwidth filtering for a specific port for ubuntu is much more complicated.

You can use tc, which can be very involved. There's also a utility called wondershaper.

But neither are as straightforward and simple as ipfw.

Jonathan wrote on March 26 2009

Using the settings above, only my live internet connection is being throttled back. The local Apache 2 server on my OS X Leopard box is still running super-fast just like always.

Any thoughts on why my local server is not slowing down?

Elliott wrote on August 27 2009

I'm Sorry but the problem for me is... I dont have ipfw installed, i cant figure out where it actually could be installed from, everything referenced freebsd, i am running rails 1.8 and apache 2 with serveral mongrel clusters. I want to simulate a production enviroment speed. I cannot figure out how in the heck to install/get ipfw into my ubuntu 9.10 environment. Then my next concern is, will it jack up my apache/mongrel setup which took me hours to figure out. Please advise... anyone. thanks.

Steve wrote on March 8 2010

i found my own answer eventually : http://info.iet.unipi.it/~luigi/dummynet/

Steve wrote on March 9 2010

Add Comment

(required, won't be displayed)

(Use Markdown syntax)