Docs TrafficShaping » History » Revision 9

« Previous | Revision 9/15 (diff) | Next »
zkv, 2008-11-21 23:12

Traffic Shaping

Module: core


Starting with 1.3.8, lighttpd supports limiting the bandwidth for a single connection or config context like a virtual host or a URL.


Limit the throughput for each single connection to the given limit in kbyte/s
Default: 0 (no limit)

Limit the throughput for all connections to the given limit in kbyte/s
Default: 0 (no limit)

If you want to specify a limit for a special virtual server use:

    $HTTP["host"] == "" {
      server.kbytes-per-second = 128

which will override the default for this host.


Keep in mind that a limit below 32kb/s might actually limit the traffic to 32kb/s.
This is caused by the size of the TCP send buffer.

Selective traffic shaping plugin(>=1.5-svn)

There is a small plugin to use selective traffic shaping on a per-connection base. You can e.g. use php and do:

 header("X-LIGHTTPD-KBytes-per-second: 50");
 header("X-Sendfile: /path/to/file");

to set the speed of the current connection.

Plugin options

speed.just-copy-header = "enable"
Use this on the frontend to just copy the header from the response to the request header (forward it to the backend)
Default: "disabled" (just use it)

speed.use-request = "enable"
Use this on the backend to fetch the speed from the request. This is not useful on the frontend, i think :)
Default: "disabled" (don't look in the request headers)

Download here:

Updated by zkv over 14 years ago · 9 revisions