Click to See Complete Forum and Search --> : Restricting Downloads


Odins_Son
12-28-2004, 08:47 PM
I'm running apache 2 on debian and I am hosting several sites from the same box. One of the sites has a lot of people downloading files. I was wondering the best way to restrict how fast the download goes so it wont choke off the other two sites. I also wanted to restrict how many simotanous(spelling) downloads one user can have. I am hosting these sites on a regular P2 emachine box with a regular adsl line. To what speed should I restrict downloads?

Icarus
12-29-2004, 08:09 AM
Go through the apache2.conf as all the options should be in there for this

the documentation (http://httpd.apache.org/docs-2.0/) is full of useful information

You might also want to look into iptables to limit connections

bwkaz
12-29-2004, 10:24 AM
Originally posted by Odins_Son
To what speed should I restrict downloads? You should restrict downloads to whatever your upload speed is (since you're hosting via ADSL, that speed is really low to begin with...) divided by the number of users you want connected at one time, if you want to hardcode that.

But I'm not convinced limiting their download speed is the right solution to this problem. Because if you have a 384 kilobit/sec upstream connection (which is pretty generous as far as ADSL goes), and you want 10 users to be able to download from you at once, you'll have to put the rate limit somewhere below 38 kilobits per second. That's quite a bit slower than a 56K modem. Your users will not be happy.

And even if you do that -- what happens when you only have 2 users downloading? They'll both still be stuck at 38 kilobits (just for comparison: That's about 4.7 K/sec), and the rest of your upload bandwidth will be totally wasted. Reserving bandwidth for the other site(s) is one thing; wasting it is another.

(But even reserving it for the other sites shouldn't be necessary: The TCP/IP stack uses as much bandwidth as possible for each connection, up to the point where all connections are sharing the same amount. When a new connection comes in to one of the other directories, it should take a small amount of bandwidth away from the existing connections until its transfer is finished. Its transfer will generally be tiny; that's why it doesn't get a lot of bandwidth. But the user shouldn't notice this, unless the number of current connections is so high (like 10) that the limit on all of them is very low.)

What you should really do if you have a high-traffic site is not host it on an ADSL connection. The upload speed is too slow. But failing that, you should just limit the number of connections to your server (or perhaps just that directory, if Apache lets you do that) to a very small number -- say, 5 or 6. That way you're not going to starve any one connection, and all the connections at any time will share all your bandwidth.