Login   Register  
PHP Classes

QoS Bandwidth Throttle in PHP: Limit the speed of files served for download

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

  Author Author  
Picture of Artur Graniszewski
Name: Artur Graniszewski is available for providing paid consulting. Contact Artur Graniszewski .
Classes: 13 packages by
Country: Poland Poland
Age: 32
All time rank: 3315 in Poland Poland
Week rank: 222 Up9 in Poland Poland Down
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
This class can be used to limit (throttle) the speed of files served for download.

It intercepts the PHP script output by setting a buffering handler that is called every time a given number of bytes are served to the browser.

The class measures the time since the last time the PHP output buffer was flushed and hold on PHP for a while if the average download speed is above a given limit.

There are three different bandwidth shaping mechanisms to ensure adequate Quality of Service:

1) burst transfer rate will be switched off after sending X bytes to the user (this can be helpful to send small images quickly, and limit the download speed of huge files)

2) burst transfer rate will be switched off after given period of time in seconds, then it will revert to the standard throttle speed

3) burst transfer rate will not be activated at all, the download speed limit will be constant during the whole downloading process (in this case $config->burstLimit must be equal to the $config->rateLimit)

  Classes of Artur Graniszewski  >  QoS Bandwidth Throttle in PHP  >  Download Download .zip .tar.gz  >  Support forum Support forum (2)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: QoS Bandwidth Throttle in PHP
Base name: bandwidth-throttler
Description: Limit the speed of files served for download
Version: 1.1.5
PHP version: 5.2.0
License: GNU Lesser General Public License (LGPL)
All time users: 1604 users
All time rank: 2246
Week users: 3 users
Week rank: 590 Up
  Groups   Screenshots Screenshots   Rate classes User ratings  
  Applications   Related pages   Files Files  

Group folder image HTTP HTTP protocol clients, headers and cookies View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Files and Folders Listing, accessing and manipulating files and folders View top rated classes
Group folder image Systems administration System configuration and management View top rated classes
Group folder image Performance and optimization Tools to measure and optimize the performance of systems View top rated classes

  Files folder image Screenshots  
File Role Description
Accessible without login Image file speed_decrease.PNG Screen Bandwidth throttling in practice

  Innovation Award  
PHP Programming Innovation award nominee
January 2011
Number 2

Prize: One copy of DWebPro Standard License
If too many users access a server to download files or other resources, the server may reach to the bandwidth usage limit and the access to the server may become too slow to all users.

A solution for this problem consists in throttling the download speed, i.e., limiting the speed by which the files are served to the users that are downloading them.

This class implements a clever download speed throttling approach controlled by PHP.

It consists in capturing the output of the download scripts into a buffer, flush the buffer at a rate that does not exceed a given limit by introducing eventual pauses if the file is served at a speed above the limit.

Manuel Lemos

  User ratings  
RatingsUtility Consistency Documentation Examples Tests Videos Overall Rank
All time: Good (96%) Good (96%) Good (93%) Good (92%) - - Sufficient (76%) 45
Month: Not yet rated by the users

  Applications that use this package  
No pages of applications that use this class were specified.
Add link image If you know an application of this package, send a message to the author to add a link here.

  Related pages  
Bandwidth throttling [Definition]
Definition of the bandwidth throttling on Wikipedia
Rate limiting [Definition]
Definition on Wikipedia
Project homepage
Project homepage (polish version)

  Files folder image Files  
File Role Description
Plain text file throttler.php Class Main class
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file example2.php Example Example script using data size as the bandwidth limit factor
Accessible without login Plain text file license.txt Lic. LPGP license
Accessible without login Plain text file readme.txt Doc. Documentation

Install with Composer Install with Composer - Download Download all files: bandwidth-throttler.tar.gz bandwidth-throttler.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.