Posted by: Airtower | 2010-08-06

Data rate limiting with Apache

Today I started to create a test environment for a not-yet-written video stream client. The problem: How do I create a HTTP live video stream to test? I tried ffserver, but it wouldn’t work. Icecast might be interesting, but the stream has to play on Android, which does not support Theora video. In the end, I decided to look if I could find a way to use a normal web server (aka Apache) and limit the transmission data rate to simulate a live stream.

Now I’ve been working with Apache a lot, but this is something I never needed to do. Some online searching showed a number of Apache modules for that purpose, and I decided to use the one for which there is a Gentoo ebuild (and it looked most powerful anyway): mod_cband.

After installing www-apache/mod_cband, I set up a virtual host for my video tests:

<VirtualHost *:80>
        DocumentRoot "/var/www/video"
        CustomLog /var/log/apache2/access_log combined
        ErrorLog /var/log/apache2/error_log

        <Directory /var/www/video>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all

        CBandRemoteSpeed 700kbps 3 3

As you can see, my mod_cband configuration is rather short. The line sets the limits per remote client, which in this case are a data rate of 700 kbps, 3 requests per second and 3 open connections. I chose 700 kbps because it’s approximately the date rate of the video I used for testing. The other limits aren’t interesting for me, so they’re just randomly chosen. Maybe not optimal, but good enough. 🙂

mod_cband can do a lot more that I don’t need right now. If you’re interested, you might want to look at the documentation or this tutorial.


Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: