How to increase limits on sockets on osx for load testing?

我怕爱的太早我们不能终老 提交于 2019-11-27 17:01:48

(answer updated to use -S as several commenters suggested)

$ sysctl kern.maxfiles
kern.maxfiles: 12288
$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 10240
$ sudo sysctl -w kern.maxfiles=1048600
kern.maxfiles: 12288 -> 1048600
$ sudo sysctl -w kern.maxfilesperproc=1048576
kern.maxfilesperproc: 10240 -> 1048576
$ ulimit -S -n
256
$ ulimit -S -n 1048576
$ ulimit -S -n
1048576

One more thing: Limit on ports is 65535. So you may not get as many as you want to.

Jeremy Friesner

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!