AE::Socket tcp_server uses 100% CPU if too many clients try to connect
Marc Lehmann
schmorp at schmorp.de
Sun Mar 27 23:02:46 CEST 2016
On Sun, Mar 27, 2016 at 10:19:19PM +0200, Juhász Péter <peter.juhasz83 at gmail.com> wrote:
> I realize that what actually happens is that the process runs out of
> file descriptors (of which the default limit is indeed 1024), so it's no
> surprise that the server can't serve any more clients. However, the 100%
> CPU usage seems like a bug to me, as this behavior can be abused to deny
> resources from other services running on the same machine.
I agree, the bug, however, is in your kernel (which is linux, right? linux
doesn't remove new connection requests as required by posix) and/or app
(e.g. twiggy), which sets no limits itself.
There is nothing that AnyEvent can do in this situation, other than
crashing, freezing, or retrying until the problem is rectified, and
anyevent choose the latter, as it is arguably the correct behaviour.
> where accept fails, sets $! to Errno::EMFILE, but for some reason the
> callback seems to be called repeatedly.
yes, the kernel should simply fail the connection, after which things
should return to normal eventually. it doesn't and therfore wakes up the
program immediatelly again.
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
-=====/_/_//_/\_,_/ /_/\_\
More information about the anyevent
mailing list