emfile error

Alex Arnon alex_arnon@REDACTED
Tue Dec 4 08:55:19 CET 2001


You should try throttling the accept rate - set a limit ot the number of
concurrent connections, and simply stop accepting once that is
exhausted. You can also possibly increase the listen queue size.
Just like memory and disk space, descriptors are a finite resource; you
should always write your servers with limits in mind.


-----Original Message-----
From: Rick Pettit [mailto:rpettit@REDACTED]
Sent: Monday, December 03, 2001 11:44 PM
To: erlang-questions@REDACTED
Subject: emfile error



I have an erlang process which runs as a concurrent TCP server.  It
functions as a gateway between non-erlang processes and Erlang
processes.

The server listens on a well-known TCP port and spawns a child to handle
each request.  The child will parse TCP input and forward the request
via
Erlang messaging to the appropriate Erlang server, waiting for a
response
(another Erlang message) before responding over TCP and closing the TCP
connection.

The problem is that when the server is hit hard the clients receive an
emfile error, which I understand could be the result of a UNIX process
(the erlang node, in this case) running out of descriptors.

Is this a known problem with concurrent erlang servers?  I would not
expect this same error if my server was in C and it fork()'d children,
as
each child would then have its own descriptor table and would have very
few entries in it (stdin, stdout, stderr, TCP client socket).

I wonder if the entire node appears to the host OS as a single process
(perhaps one with many threads), in which case I would expect this
problem
with most any concurrent server.

Please forgive me if I am doing something silly or am missing some
fundemental coding convention that would have alleviated this problem.

Rick




More information about the erlang-questions mailing list