[erlang-questions] Cowboy back pressure

Alexander Petrovsky <>
Tue Nov 4 13:57:46 CET 2014


>
> 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/

Do I understand correctly, that the {backlog, Backlog} option set the
socket backlog size. 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?

2014-11-04 15:26 GMT+03:00 Loïc Hoguin <>:

> 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
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
> --
> Loïc Hoguin
> http://ninenines.eu
>



-- 
Петровский Александр / Alexander Petrovsky,

Skype: askjuise
Phone: +7 914 8 820 815
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141104/a2df8580/attachment.html>


More information about the erlang-questions mailing list