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