Done reading? subscribe: To get an automatic feed of all future posts subscribe here.
Link to This Post:
Posted in Development | Share/Save/E-mail
Tuning the Linux Kernel for many tcp connections
Posted by David Cancel
- October 16, 2008 at 5:07 pm PST | Share/Save/E-mail
If you’re running highly loaded Linux servers like us you’ll find these Linux Kernel tuning tips useful. I’ve been using a similar set of tuning params for a while but this is a nice summary.
Save yourself some time and tune the kernel tcp settings before testing with lots of connections, or your test will fail and you’ll see lots of Out of socket memory messages (and if you are masquerading, nf_conntrack: table full, dropping packet.) Here are the sysctl settings I ended up with – YMMV, but these will probably do:
# General gigabit tuning:
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_syncookies = 1
# this gives the kernel more memory for tcp
# which you need with many (100k+) open socket connections
net.ipv4.tcp_mem = 50576 64768 98152
net.core.netdev_max_backlog = 2500
# I was also masquerading the port comet was on, you might not need this
net.ipv4.netfilter.ip_conntrack_max = 1048576
Put these in /etc/sysctl.conf then run sysctl -p to apply them. No need to reboot, now your kernel should be able to handle a lot more open connections, yay.
Source: A Million-user Comet Application with Mochiweb, Part 1
- David
Recent Posts
“Lookery Resurrected: Audience Networks For Pubs Calling it “Lookery Prequel, Inc.,”…”
“Lookery Resurrected: Audience Networks For Pubs Calling it “Lookery Prequel, Inc.,” Scott Rafer has rolled ...
Posted by Scott Rafer, February 26, 2010 at 6:04 pm“I think we’ve begun to see this already in how Bravo, HBO and others have jumped to partner with…”
“I think we’ve begun to see this already in how Bravo, HBO and others have ...
Posted by Scott Rafer, February 25, 2010 at 2:10 pm“I think we’ve begun to see this already in how Bravo, HBO and others have jumped to partner with…”
“I think we’ve begun to see this already in how Bravo, HBO and others have ...
Posted by Scott Rafer, February 25, 2010 at 2:10 pm