sysctl kern.ipc.somaxconn=4096
increase max open socket
sysctl kern.ipc.maxsockets=204800
Mbufs are allocated in units called nmbclusters (sometimes called mbuf clusters). While the size of a mbuf varies, one cluster is about 2KB. You can use simple math to figure out how much RAM your current nmbcluster setting requires, and then calculate sensible values for your system and applications. This example machine has 25,600 nmbclusters, which means the kernel has reserved about 50MB RAM for networking purposes.
Memory allocated for mbufs cannot be used for any other purpose, so preallocating gigs of RAM for mbufs will actually hurt system performance.
sysctl kern.ipc.nmbclusters=33792
show current mbuf cluster usage
netstat -m
increase max open file desctiptor
sysctl kern.maxfiles=32768
sysctl kern.maxfilesperproc=16384