Project

General

Profile

Actions

Traffic Shaping

Description

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

Options

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

server.kbytes-per-second
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"] == "www.example.org" {
      server.kbytes-per-second = 128
    }

which will override the default for this host.

Note:

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 defined by backend script

Since lighttpd 1.4.46 (#954)) a backend script can selectively request traffic shaping on a per-request basis. You can e.g. use php and do:

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

to set the speed of the current response.

Updated by gstrauss over 3 years ago · 15 revisions