Forum Moderators: phranque

Message Too Old, No Replies

How to limit download speeds & bandwidth usage?

Limit down speed

         

hotgoalz

12:07 pm on Jan 14, 2007 (gmt 0)

10+ Year Member



Hi Guys

I am hosting some video files, and I just burned up 50GB in 2 day as people link to the location from all over the place.

I would like to avoid the "Limit Bandwidth Exceeded" page, and naturally I also do not want to supply much more bandwidth for this project per month. The only solution I see is to slow down the download.

Here are my questions:

* How can I make sure that each user can only download one file at a time?
* How can I limit the download speed to 75% of the user speed?

Thanks in advance ...

Batt

adamnichols45

11:29 pm on Jan 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I didnt think some thing like this was possible!

If it is then we must be able to limit each user to an allocated amount of bandwidth per month etc etc.

Nutter

1:42 pm on Jan 15, 2007 (gmt 0)

10+ Year Member



A couple of ideas, although I don't know if either one would work. Both of them will require you routing your downloads through some type of script. PHP is what I'm familar with, but other languages would probably work - assuming my thinking works at all :)

At the beginning of the download store a variable in the $_SESSION array. Let's call it $_SESSION['video_downloading'] and set it to true while the download script is running. After the file is sent clear the variable. Then, if the script is run for another file while one is already downloading it can check for that variable and stop the download if the variable is true. A cookie would do pretty much the same thing.

Or, maybe store an identifier (ip address, user-agent, something like that) in a database along with the time the download starts. If they've downloaded in the last 5 minutes, or whatever time you want, don't allow it.

Along the same lines as the database, store each file download along with an identifier and the date and filesize. Then, if sum(filesize) for a date range > your allowed value, don't allow the download.

Either one of these would take a script to serve the file rather than a direct link which will add to the work your server has to do.