如何增加 osx 上套接字的限制以进行负载测试?
我正在创建一个负载测试器,它使用 libev 创建大量与我正在开发的应用程序的开放 TCP 连接。目前,由于 nofiles 限制,它在 256 个连接上崩溃:
ulimit -n
256
我可以通过执行以下操作将其增加到 1024:
ulimit -n 1024
但我无法进一步增加它。理想情况下,我想将其设置为 1048576。它会给出以下错误:
ulimit: open files: cannot modify limit: Invalid argument
How can i raise the ulimit future on osx?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
(按照几位评论者的建议,答案已更新为使用 -S )
(answer updated to use -S as several commenters suggested)
还有一件事:端口限制为 65535。因此您可能无法获得您想要的数量。
One more thing: Limit on ports is 65535. So you may not get as many as you want to.
尝试以 root 身份运行(例如,在运行 ulimit 命令和程序之前执行“sudo -s”)。
请注意,我不确定一次超过 100 万个 TCP 套接字是否真的可以实现(尽管我很想听听您尝试时会发生什么;^))
另外,请查看 这个。
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.