I'm creating a load tester that uses libev to create lots of open tcp connections to an app i'm working on. Currently it bombs out at 256 connections, due to the nofiles limit:
ulimit -n
256
I can increase this to 1024 by doing the below:
ulimit -n 1024
But i cannot increase it further. Ideally i want to set it to 1048576. It gives the following error:
ulimit: open files: cannot modify limit: Invalid argument
How can i increase the ulimit further on osx?
One more thing: Limit on ports is 65535. So you may not get as many as you want to.
Try running as root (e.g. do a "sudo -s" before running the ulimit command and your program).
Note that I'm not sure that 1-million-plus TCP sockets at once is realistically achievable (although I'm interesting in hearing about what happens when you try it ;^))
Also, check out this.
(answer updated to use -S as several commenters suggested)