diff options
author | Loïc Hoguin <[email protected]> | 2011-05-09 22:01:31 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2011-05-09 22:01:31 +0200 |
commit | 5d698250b228229001ca9966a390bf1545fcd0b0 (patch) | |
tree | 9491764e4c0310f4c0d16cb120b6d64edae9c868 /src/cowboy_acceptors_sup.erl | |
parent | b3d3045cae8d90257851e87e0073c227656d3ad0 (diff) | |
download | cowboy-5d698250b228229001ca9966a390bf1545fcd0b0.tar.gz cowboy-5d698250b228229001ca9966a390bf1545fcd0b0.tar.bz2 cowboy-5d698250b228229001ca9966a390bf1545fcd0b0.zip |
Add a max_connections transport option.
Limits the number of parallel requests processed at once.
Waiting requests are kept in the accept queue.
The limit is not explicitly observed, but it should be
around the given value at any time. Defaults to 1024.
Thanks to ostinelli's benchmark to point out the issue hopefully
solved by this and the previous commit.
Diffstat (limited to 'src/cowboy_acceptors_sup.erl')
-rw-r--r-- | src/cowboy_acceptors_sup.erl | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cowboy_acceptors_sup.erl b/src/cowboy_acceptors_sup.erl index 3fbffb1..f5b2de3 100644 --- a/src/cowboy_acceptors_sup.erl +++ b/src/cowboy_acceptors_sup.erl @@ -32,8 +32,9 @@ start_link(NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts, ReqsPid) -> -spec init(list(term())) -> term(). %% @todo These specs should be improved. init([NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts, 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, ReqsPid + LSocket, Transport, Protocol, ProtoOpts, MaxConns, ReqsPid ]}, permanent, brutal_kill, worker, dynamic} || N <- lists:seq(1, NbAcceptors)], {ok, {{one_for_one, 10, 10}, Procs}}. |