This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Commit dba7e7a
Vicent Marti
statsd: Allow buffering for the clients
The new `Buffer` wrapper allow wrapping any UDP clients in a "buffering
mode" that batches incoming metrics into a buffer and eventually flushes
them to the statsd-compatible server.
The receiving server *must* support the multi-metric StatsD protocol
(namely, parsing several metrics in the same packet, separated by
newlines). Both the original StatsD and now Brubeck support this. By
sending several metrics in a single packet, we reduce the amount of
network operations (both in the client and the server) and the amount of
context switches to the kernel UDP stack, significantly increasing the
throughput of the server implementation.
The default maximum packet size has been set at 512 bytes, which is a
"safe size" to reliably transmit an atomic packet through the internet:
The MTU on the internet is 576, and the size of the IPv4 header is 20
bytes, and the UDP header 8 bytes. This leaves 548 bytes available for
user data. We cap it at 512 to add some headspace (most other UDP-based
protocols, such as DNS, do the same thing).1 parent 80ac4de commit dba7e7a
1 file changed
+62
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
17 | 35 | | |
18 | 36 | | |
19 | 37 | | |
| |||
51 | 69 | | |
52 | 70 | | |
53 | 71 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
106 | 125 | | |
107 | 126 | | |
108 | 127 | | |
| |||
200 | 219 | | |
201 | 220 | | |
202 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
203 | 247 | | |
0 commit comments