Skip to content

Instantly share code, notes, and snippets.

@tsnow
Created December 20, 2012 20:41
Show Gist options
  • Save tsnow/4348374 to your computer and use it in GitHub Desktop.
Save tsnow/4348374 to your computer and use it in GitHub Desktop.
high perf tuning freebsd webservers - @jssjr
if node['platform'] == "freebsd"
# load the http accept filter into the kernel
freebsd_kernel_module "accf_http"
# increase max files
freebsd_sysctl "kern.maxfiles" do
value 131072
end
# increase the max pending socket limit
freebsd_sysctl "kern.ipc.somaxconn" do
value 1024
end
# Recycle FIN_WAIT_2 sockets faster
freebsd_sysctl "net.inet.tcp.fast_finwait2_recycle" do
value 1
end
# Decrease FIN_WAIT timeout to 30s (default: 60s)
freebsd_sysctl "net.inet.tcp.finwait2_timeout" do
value 30000
end
# Enable keepalives for dynamic rules
freebsd_sysctl "net.inet.ip.fw.dyn_keepalive" do
value 1
end
# Decrease max segment lifetime (default: 60s)
# Note: TIME_WAIT sockets live for 2*MSL
freebsd_sysctl "sysctl net.inet.tcp.msl" do
value 30000
end
# Increase the number of TIME_WAIT sockets allowed
freebsd_sysctl "net.inet.tcp.maxtcptw" do
value 16384
end
# Increase the overall number of sockets allowed
freebsd_sysctl "net.inet.ip.portrange.first" do
value 16384 # default: 49152
end
freebsd_sysctl "net.inet.ip.portrange.last" do
value 65535
end
# Don't go into TIME_WIAT for local connections
freebsd_sysctl "sysctl net.inet.tcp.nolocaltimewait" do
value 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment