Results 1 to 5 of 5
  1. #1
    Join Date
    May 2005
    Posts
    37

    Limiting Bandwidth on a Server

    I have a site where users can download large files. However, sometimes when a user downloads, they hog all the bandwidth, thus showing down the entire website. Is there any way on Apache 2 on Windows Server 2003 to limit the bandwidth a specific IP (user) can use at a given moment?

    I want to cap the download speed for each user to 60kbps. Thanks!

  2. #2
    On Linux there is mod_throttle, not sure if there anything similar available for Windows servers. You can limit bandwidth per site on IIS.

  3. #3
    Join Date
    May 2005
    Posts
    37
    Thanks for the idea, but I need it for Apache 2 on Windows. Also, I want to do it by user rather than by website. Thanks!

  4. #4
    Join Date
    Jan 2004
    Location
    York, UK
    Posts
    371
    Originally posted by amitroy5
    Thanks for the idea, but I need it for Apache 2 on Windows. Also, I want to do it by user rather than by website. Thanks!
    One method would be to use some form of script (PPHP, perl, ...) to get the files - the user requests http://<host>/<dir>/file.php?filename=<file> and file.php reads the file and sends it no faster than 60Kb/s (or some other rate). Something like "read 6Kb and send, sleep for 0.1 secound, loop until end of file".

    If you want to limit a user over multiple connections (i.e. 60KB/s total rather than 60Kb/s per file if they are getting more than one) then you'll need to record their activiy somewhere in a DB or in the filesystem (each process would record "at time xx:xx I sent xxKb to <user>" and would check before sending anything that no more than <rate>Kb has gone in the last minute or so..

    Pros:
    * Bandwidth management, as intelegent as you can program
    * Will stop download managers using multiple streams for the same file (each user will be less of a hog)

    Cons:
    * You'll have to write it if you can't find someone who has done it before!
    * Extra complication. At least one more thing that could wrong...
    * Takes more CPU/RAM (PHP thread/proces for each download, and perhaps some SQL activity)
    * Will stop download managers using multiple streams for the same file (my irritate some of your users)

  5. #5
    Join Date
    Jan 2004
    Location
    York, UK
    Posts
    371
    Oh, and with the above technique make sure the files in question are stored outside the document root(s) configure to be visible to the world in Apache, otherwise people may work out how to bypass your script get at the file directly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •