Erlang 的最大同时打开端口数?
erlang TCP/IP 库有一些限制吗?我做了一些搜索,但找不到任何明确的答案。
我已将 ERL_MAX_PORTS 环境变量设置为 12000 并将 Yaws 配置为使用无限连接。
我编写了一个简单的客户端应用程序,它连接到我为 Yaws 编写的 appmod,并通过同时启动 X 个客户端来测试同时连接的数量。
我发现当我达到大约 100 个客户端时,Yaws 服务器停止接受更多 TCP 连接,并且客户端错误显示“
Error in process with exit value: {{badmatch,{error,socket_closed_remotely}}
我知道打开的同时连接数必须有限制,但 100 个似乎确实很低”。我已经浏览了所有雅司病文档并删除了对连接的任何限制。
这是在运行 Snow Leopard 的 2.16Ghz Intel Core 2 Duo iMac 上。
在 Vista 机器上进行的快速测试表明,在大约 300 个连接时我遇到了同样的问题。
我的测试不合理吗?即同时打开 100+ 个连接来测试 Yaws 的并发性是否愚蠢?
谢谢。
Does the erlang TCP/IP library have some limitations? I've done some searching but can't find any definitive answers.
I have set the ERL_MAX_PORTS environment variable to 12000 and configured Yaws to use unlimited connections.
I've written a simple client application that connects to an appmod I've written for Yaws and am testing the number of simultaneous connections by launch X number of clients all at the same time.
I find that when I get to about 100 clients, the Yaws server stops accepting more TCP connections and the client errors out with
Error in process with exit value: {{badmatch,{error,socket_closed_remotely}}
I know there must be a limit to the number of open simultaneous connections, but 100 seems really low. I've looked through all the yaws documentation and have removed any limit on connections.
This is on a 2.16Ghz Intel Core 2 Duo iMac running Snow Leopard.
A quick test on a Vista Machine shows that I get the same problems at about 300 connections.
Is my test unreasonable? I.e. is it silly to open 100+ connections simultaneously to test Yaws' concurrency?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
增加打开文件的最大数量
您似乎遇到了系统限制,请尝试使用Snow Leopard 上的 Python,如何打开 >255 个套接字?
Erlang 本身有 1024 个限制:
来自 http://www.erlang.org/doc/man/erlang.html
默认可以同时打开的最大端口数是1024,但是可以通过环境变量ERL_MAX_PORTS进行配置。
编辑:
系统调用 listen()
有一个参数 backlog 决定可以排队的请求数量,请检查建立连接的请求之间的延迟是否有帮助。这可能是你的问题。
It seems you hit a system limitation, try to increase the max number of open files using
Python on Snow Leopard, how to open >255 sockets?
Erlang itself has a limit of 1024:
From http://www.erlang.org/doc/man/erlang.html
The maximum number of ports that can be open at the same time is 1024 by default, but can be configured by the environment variable ERL_MAX_PORTS.
EDIT:
The system call listen()
has a parameter backlog which determines how many requests can be queued, please check whether a delay between requests to establish connections helps. This could be your problem.
Erlang 效率指南中报告了所有 Erlang 系统限制:
http://erlang.org/ doc/efficiency_guide/advanced.html#id2265856
从开放端口部分读取:
All Erlang system limits are reported in the Erlang Efficiency Guide:
http://erlang.org/doc/efficiency_guide/advanced.html#id2265856
Reading from the open ports section:
在尝试了每个人的建议并搜索了 Erlang 文档之后,我得出的结论是,我的问题是 Yaws 无法跟上负载。
在同一台机器上,Apache Http Components Web 服务器(非阻塞 I/O)在处理相同阈值的连接时不会出现相同的问题。
感谢您的帮助。我将转向其他基于 erlang 的 Web 服务器,例如 Mochiweb。
After trying out everybody's suggestion and scouring the Erlang docs, I've come to the conclusion that my problem is with Yaws not being able to keep up with the load.
On the same machine, an Apache Http Components web server (non-blocking I/O) does not have the same problems handling connections at the same thresholds.
Thanks for all your help. I'm going to move on to other erlang based web servers, like Mochiweb.