Skip to content

Commit

Permalink
udp listener: add os buffer size notes & change default port
Browse files Browse the repository at this point in the history
- using 8092 as the default port because it's similar to the rest of
  the TICK stack (InfluxDB, for example, uses 8083, 8086, 8088, etc.).
  didn't want to use 8125 because that conflicts with statsd.

closes influxdata#758
  • Loading branch information
sparrc committed Mar 1, 2016
1 parent e1f30ae commit 3b496ab
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 3 deletions.
62 changes: 61 additions & 1 deletion plugins/inputs/udp_listener/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This is a sample configuration for the plugin.
```toml
[[inputs.udp_listener]]
## Address and port to host UDP listener on
service_address = ":8125"
service_address = ":8092"

## Number of UDP messages allowed to queue up. Once filled, the
## UDP listener will start dropping packets.
Expand All @@ -29,3 +29,63 @@ This is a sample configuration for the plugin.
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "influx"
```

## A Note on UDP OS Buffer Sizes

Some OSes (most notably, Linux) place very restricive limits on the performance
of UDP protocols. It is _highly_ recommended that you increase these OS limits to
at least 8MB before trying to run large amounts of UDP traffic to your instance.
8MB is just a recommendation, and can be adjusted higher.

### Linux
Check the current UDP/IP receive buffer limit & default by typing the following
commands:

```
sysctl net.core.rmem_max
sysctl net.core.rmem_default
```

If the values are less than 8388608 bytes you should add the following lines to
the /etc/sysctl.conf file:

```
net.core.rmem_max=8388608
net.core.rmem_default=8388608
```

Changes to /etc/sysctl.conf do not take effect until reboot.
To update the values immediately, type the following commands as root:

```
sysctl -w net.core.rmem_max=8388608
sysctl -w net.core.rmem_default=8388608
```

### BSD/Darwin

On BSD/Darwin systems you need to add about a 15% padding to the kernel limit
socket buffer. Meaning if you want an 8MB buffer (8388608 bytes) you need to set
the kernel limit to `8388608*1.15 = 9646900`. This is not documented anywhere but
happens
[in the kernel here.](https://github.com/freebsd/freebsd/blob/master/sys/kern/uipc_sockbuf.c#L63-L64)

Check the current UDP/IP buffer limit by typing the following command:

```
sysctl kern.ipc.maxsockbuf
```

If the value is less than 9646900 bytes you should add the following lines
to the /etc/sysctl.conf file (create it if necessary):

```
kern.ipc.maxsockbuf=9646900
```

Changes to /etc/sysctl.conf do not take effect until reboot.
To update the values immediately, type the following commands as root:

```
sysctl -w kern.ipc.maxsockbuf=9646900
```
4 changes: 2 additions & 2 deletions plugins/inputs/udp_listener/udp_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ var dropwarn = "ERROR: Message queue full. Discarding line [%s] " +

const sampleConfig = `
## Address and port to host UDP listener on
service_address = ":8125"
service_address = ":8092"
## Number of UDP messages allowed to queue up. Once filled, the
## UDP listener will start dropping packets.
allowed_pending_messages = 10000
## UDP packet size for the server to listen for. This will depend
## on the size of the packets that the client is sending, which is
## usually 1500 bytes.
## usually 1500 bytes, but can be as large as 65,535 bytes.
udp_packet_size = 1500
## Data format to consume. This can be "json", "influx" or "graphite"
Expand Down

0 comments on commit 3b496ab

Please sign in to comment.