Project

General

Profile

Understanding Traffic Shaping settings on Lighttpd2

Added by anto over 13 years ago

Hello everybody,

Since there is no forum in Lighttpd2 project, so I post this here. I hope it is alright.

One of the features that I like on Lighttpd (over nginx for instance) is the advanced traffic shaping. I like that feature more on Lighttpd2, but I still can not entirely understand how to implement the settings.

Suppose we want to limit the link usage for Lighttpd to 500 mbit/s out of the available link rate. And suppose there are several vhosts on Lighttpd which we also want to limit their link usage of base on the type of traffics. Hierarchically, that is depicted on the diagram at the bottom. It may not be necessary or there might be another ways to implement the settings but for the purpose of understanding the settings, I think that should cover all combinations.

The following are the settings that I can imagine in implementing that.

setup {
   module_load "mod_vhost";
   #... more settings ... 
}

vhost.map [
   "vhostone.com":     vhostone,
   "www.vhostone.com": vhostone,
   "vhosttwo.com":     vhosttwo,
   "www.vhosttwo.com": vhosttwo,

   #... more vhost maps ... 

   "default": defaultdom
];

io.throttle_pool "global" => 500mbit;

#... more global settings ... 

io.throttle_pool "vhost1" => 100mbit;

vhostone {

   io.throttle_pool "constant" => 60mbit;

   if req.path =^ "/download/" {
      io.throttle_ip 4mbit;
      #... more settings ... 
   }

   if req.path =^ "/streaming/" {
      io.throttle 1mbyte => 2mbit;
      #... more settings ... 
   }

   io.throttle_pool "bursty" => 40mbit;

   if req.path =^ "/chat/" {
      io.throttle_pool "chat" => 10mbit;
      #... more settings ... 
   }

   if req.path =^ "/web/" {
      io.throttle 4mbit;
      #... more settings ... 
   }

    #... more vhostone settings ...
}

io.throttle_pool "vhost2" => 200mbit;

vhosttwo {

   io.throttle_pool "constant" => 80mbit;

   if req.path =^ "/download/" {
      io.throttle_ip 4mbit;
      #... more settings ... 
   }

   if req.path =^ "/streaming/" {
      io.throttle 1mbyte => 2mbit;
      #... more settings ... 
   }

    #... more vhosttwo settings ...
}

defaultdom {
    #... all default domain settings ...
}

First thing that I am really not sure of is the way to assign the "vhost1" and "vhost2" pools to the "global" pool, the "constant" and "bursty" pools to the "vhost1" pool, the "/download/" and "/streaming/" paths to the "constant" pool of vhostone, etc.

Basically, how do we assign something to a "pool"? How can we make sure that the "constant" pool of vhostone will be assigned to the "vhost1" pool? And do we have to have unique pool name per vhost instead of using the same pool name, e.g. the pool name "constant" as above?

Thanks in advance for your response.

Kind regards,

Anto

                                                                                   |-------------------------|
                                                                                   |        "global"         |
                                                                                   |-------------------------|
                                                                                   |       500 mbit/s        |
                                                                                   |-------------------------|
                                                        ________________________________________|____________________________________
                                                       |                                                                             |
                                          |------------------------|                                                    |-------------------------|
                                          |       "vhost one"      |                                                    |        "vhost two"      |
                                          |------------------------|                                                    |-------------------------|
                                          |       100 mbit/s       |                                                    |        200 mbit/s       |
                                          |------------------------|                                                    |-------------------------|
                            ___________________________|___________________________
                           |                                                       |
              |-------------------------|                             |-------------------------|
              |         "constant"      |                             |         "bursty"        |
              |-------------------------|                             |-------------------------|
              |         60 mbit/s       |                             |        40 mbit/s        |
              |-------------------------|                             |-------------------------|
              _____________|_____________                             _____________|_____________
             |                           |                           |                           |
|-------------------------| |-------------------------| |-------------------------| |-------------------------|
|        /download/       | |       /streaming/       | |          "chat"         | |         /web/           |
|-------------------------| |-------------------------| |-------------------------| |-------------------------|
|     4 mbit/s per IP     | |  2 mbit/s after 1mbyte  | |         10 mbit/s       | | 4 mbit/s per connection |
|-------------------------| |-------------------------| |-------------------------| |-------------------------|