[erlang-questions] Cowboy back pressure
Loïc Hoguin
essen@REDACTED
Tue Nov 4 14:03:14 CET 2014
On 11/04/2014 02:57 PM, Alexander Petrovsky wrote:
> As explained in the documentation for max_connections, this is a
> soft limit.
>
>
> I can't find any thing about soft limit in
> http://ninenines.eu/docs/en/cowboy/HEAD/guide/architecture/
http://ninenines.eu/docs/en/ranch/1.0/manual/ranch/#types
> Do I understand correctly, that the {backlog, Backlog} option set the
> socket backlog size.
Yes.
> The {max_connections, MaxConnections} option set
> the soft limit connections count (i.e. accepted connections?), and if
> the real connections count gather then MaxConnections, cowboy do
> https://github.com/ninenines/ranch/blob/master/src/ranch_conns_sup.erl#L127,
> but what happens with after that? Can you explain please?
Acceptors only accept connections when the number is below the limit you
configured. So first the number gets above the limit, then Ranch
acceptors suspend temporarily (they can only stop after accepting a
connection, that's why it can go above), then Ranch resumes acceptors
one at a time as soon as a spot opens.
> 2014-11-04 15:26 GMT+03:00 Loïc Hoguin <essen@REDACTED
> <mailto:essen@REDACTED>>:
>
> Hi,
>
> As explained in the documentation for max_connections, this is a
> soft limit. Messages being sent asynchronously, it can go higher
> than the limit, even more significantly if the number of acceptors
> is close to the maximum number of connections.
>
> That said, if you need to reduce the number of connections, why do
> you have so many acceptor processes? The documentation says that 100
> is already a large enough number. If you want to accept connections
> slower, you should reduce it, not increase it.
>
>
> On 11/04/2014 02:21 PM, Alexander Petrovsky wrote:
>
> Hi!
>
> Until recently, I thought that I can do "connection" back
> pressure from
> cowboy like:
>
> NbAcceptors = 256,
> Backlog = 256,
> MaxConnections = 256,
>
> cowboy:start_http(http, NbAcceptors, [{port, ...}, {backlog,
> Backlog}, {max_connections, MaxConnections}], [{env, ...}]),
>
>
> But some times ago I'm observed that I can't, the
> "ranch_server:count___connections/1" says that active ranch
> connection was
> gather than 256.
> While the "ss -lt" show me that ranch socket backlog is 256. And
> I can't
> understand why?
>
> - Does the "ranch_server:count___connections/1" show not only active
> connections in ESTABLISHED state, but and the TIME_WAIT state?
> - How can I properly do connection back pressure with ranch and
> cowboy?
>
> --
> Петровский Александр / Alexander Petrovsky,
>
> Skype: askjuise
> Phone: +7 914 8 820 815
>
>
>
> _________________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
> http://erlang.org/mailman/__listinfo/erlang-questions
> <http://erlang.org/mailman/listinfo/erlang-questions>
>
>
> --
> Loïc Hoguin
> http://ninenines.eu
>
>
>
>
> --
> Петровский Александр / Alexander Petrovsky,
>
> Skype: askjuise
> Phone: +7 914 8 820 815
>
--
Loïc Hoguin
http://ninenines.eu
More information about the erlang-questions
mailing list