I was trying to benchmark a TCP based file server on Mac OS X. The server is running latest Node.js (0.8.2), while the client to push the server is written in go. ‘Go’ can start thousands of concurrent goroutines easily. I got error when there are hundreds of concurrent clients.


  1. increate max open files
    $ sysctl -a | grep files
    kern.maxfiles = 12288
    kern.maxfilesperproc = 10240
    kern.maxfiles and kern.maxfilesperproc were small numbers, they need to be increased:
    $ sudo sysctl -w kern.maxfiles=12288
    $ sudo sysctl -w kern.maxfilesperproc=10240
    after this, you can increase your account’s limit by ulimit -n:
    $ ulimit -n 10240
  2. increate max sockets
    $ sysctl -a | grep somax
    kern.ipc.somaxconn: 2048
    It was a small number and need to be increased:
    $ sudo sysctl -w kern.ipc.somaxconn=2048