(from http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1)
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:
$ cat /etc/sysctl.conf
# General gigabit tuning:
net.core.rmem_max = 16777216