Erlang 的最大同时打开端口数?

发布于 2024-08-19 08:06:20 字数 577 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

Smile简单爱 2024-08-26 08:06:20

增加打开文件的最大数量

$ ulimit -n 500

您似乎遇到了系统限制,请尝试使用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

$ ulimit -n 500

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.

暗藏城府 2024-08-26 08:06:20

Erlang 效率指南中报告了所有 Erlang 系统限制:

http://erlang.org/ doc/efficiency_guide/advanced.html#id2265856

开放端口部分读取:

同时最大数量
开放的 Erlang 端口默认为 1024。
该限制最多可以提高到
268435456 启动时(参见环境
erlang(3) 中的变量 ERL_MAX_PORTS)
最大开放限额268435456
端口至少为 32 位
建筑遥不可及
由于内存不足。

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:

The maximum number of simultaneously
open Erlang ports is by default 1024.
This limit can be raised up to at most
268435456 at startup (see environment
variable ERL_MAX_PORTS in erlang(3))
The maximum limit of 268435456 open
ports will at least on a 32-bit
architecture be impossible to reach
due to memory shortage.

薔薇婲 2024-08-26 08:06:20

在尝试了每个人的建议并搜索了 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文