Permalink
Browse files

Seems that 8Mb is the OSX default.

To avoid errors when starting up statsd, let's lower
the default to 8Mb. Thanks to Aditya Ivaturi (aditya at topsy com)
  • Loading branch information...
1 parent 9c39a5a commit b4c91056691338ca72b545ddd9edc50a34194345 @cosimo committed Jan 30, 2013
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/Net/Statsd/Server.pm
View
@@ -29,9 +29,10 @@ use constant {
DEFAULT_CONFIG_FILE => 'localConfig.js',
DEFAULT_FLUSH_INTERVAL => 10000,
DEFAULT_LOG_LEVEL => 'info',
+ RECEIVE_BUFFER_MB => 8,
};
-our $VERSION = '0.09_01';
+our $VERSION = '0.09_02';
our $logger;
# }}}
@@ -644,10 +645,11 @@ sub start_server {
);
# Bump up SO_RCVBUF on UDP socket, to buffer up incoming
- # UDP packets, to avoid massive packet loss when load
- # is very high.
- setsockopt($self->{server}->fh, SOL_SOCKET, SO_RCVBUF, 16*1024*1024)
- or die "Couldn't set SO_RCVBUF: $!";
+ # UDP packets, to avoid significant packet loss under load.
+ # Read more: http://bit.ly/10eeFoE
+ setsockopt($self->{server}->fh, SOL_SOCKET,
+ SO_RCVBUF, RECEIVE_BUFFER_MB * 1048576)
+ or die "Couldn't set SO_RCVBUF: $!";
# Management interface (TCP, for 'stats' command, etc...)
$self->{mgmtServer} = AnyEvent::Socket::tcp_server $mgmt_host, $mgmt_port, sub {

0 comments on commit b4c9105

Please sign in to comment.