1782
|
1 #summary Connection-level rate limiting
|
|
2 #labels Stage-Beta
|
|
3
|
|
4 = Introduction =
|
|
5
|
|
6 On some servers, especially public ones, it is desired to make sure that everyone gets their fair share of system resources (and no more).
|
|
7
|
|
8 mod_limits allows you to specify traffic bandwidth limits, preventing any single connection hogging the server's CPU, RAM and bandwidth.
|
|
9
|
|
10 = Details =
|
|
11
|
|
12 mod_limits detects when a connection has exceeded its traffic allowance and temporarily ignores a connection. Due to the way TCP and the OS's network API works no data is lost, only slowed.
|
|
13
|
|
14 = Configuration =
|
|
15 Currently mod_limits is configured per connection type. The possible connection types are:
|
|
16
|
|
17 * c2s
|
|
18 * s2sin
|
|
19 * s2sout
|
|
20 * component
|
|
21
|
|
22 The limits are specified like so in the *global* section of your config (they cannot be per-host):
|
|
23
|
|
24 {{{
|
|
25 limits = {
|
|
26 c2s = {
|
|
27 rate = "3kb/s";
|
|
28 burst = "2s";
|
|
29 };
|
|
30 s2sin = {
|
|
31 rate = "10kb/s";
|
|
32 burst = "5s";
|
|
33 };
|
|
34 }
|
|
35 }}}
|
|
36
|
|
37 All units are in terms of _bytes_, not _bits_, so that "kb/s" is interpreted as "kilobytes per second", where a kilobyte is 1000 bytes.
|
|
38
|
|
39 = Compatibility =
|
|
40 || 0.9 || Works ||
|
|
41 || 0.8 || Doesn't work(`*`) ||
|
|
42
|
|
43 (`*`) This module can be made to work in 0.8 if you do two things:
|
|
44
|
|
45 # Install [http://hg.prosody.im/0.9/raw-file/d46948d3018a/util/throttle.lua util.throttle] into your Prosody source's util/ directory.
|
|
46 # If you use libevent apply [http://prosody.im/patches/prosody08-mod-limits-fix.patch this patch] to net/server_event.lua. |