From 830cfc002e992126a2c605594f25d40a5a193968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 30 Jan 2012 08:09:33 +0100 Subject: Move max_connections check directly inside cowboy_listener This is a big change in the internal cowboy API. This should not have any impact on existing applications as only the acceptor is expected to use these API calls. The function cowboy_listener:wait/3 has been removed. max_connections checking now occurs directly in cowboy_listener:add_connection/3. If the pool is full and the acceptor has to wait, then it doesn't return, waiting for a free space to be available. To accomodate these changes, it is now cowboy_listener that will inform the new connection that it is ready by sending {shoot, self()}. This should be a great improvement to the latency of responses as there is one less message to wait for before the request process can do its work. Overall the performance under heavy load should also be improved as we greatly reduce the number of messages sent between the acceptor and the listener process. --- src/cowboy_acceptors_sup.erl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/cowboy_acceptors_sup.erl') diff --git a/src/cowboy_acceptors_sup.erl b/src/cowboy_acceptors_sup.erl index 17849a6..625028c 100644 --- a/src/cowboy_acceptors_sup.erl +++ b/src/cowboy_acceptors_sup.erl @@ -34,10 +34,9 @@ start_link(NbAcceptors, Transport, TransOpts, init([NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts, ListenerPid, ReqsPid]) -> {ok, LSocket} = Transport:listen(TransOpts), - MaxConns = proplists:get_value(max_connections, TransOpts, 1024), Procs = [{{acceptor, self(), N}, {cowboy_acceptor, start_link, [ LSocket, Transport, Protocol, ProtoOpts, - MaxConns, ListenerPid, ReqsPid + ListenerPid, ReqsPid ]}, permanent, brutal_kill, worker, []} || N <- lists:seq(1, NbAcceptors)], {ok, {{one_for_one, 10, 10}, Procs}}. -- cgit v1.2.3