Ranch 2.0 adds support for multiple connection supervisors.
Ranch 1.x had a bottleneck because it used only a single connection supervisor. This was more evident when many connections were dropped at once as the supervisor couldn't keep up and failed to accept new connections while cleaning up the old ones. Ranch 2.0 behaves much better in this scenario by default. Multiple connection supervisors also helps with concurrently accepting new connections.
Ranch 2.0 also adds experimental support for opening more than one listening socket on a single port.
Starting with Ranch 2.0 we are also providing a Prometheus collector as a separate project as well as a Grafana dashboard.
Ranch 2.0 is compatible with Erlang/OTP 21.0 onward. Support for Erlang/OTP 19 and 20 has been removed.
num_conns_supsoption has been added. It allows configuring the number of connection supervisors. It now defaults to
num_accceptors. The old behavior can be obtained by setting this value to 1.
loggeroption is no longer experimental. It now defaults to
ranch_servergoes down. It is no longer necessary to embed
ranch_supand the recommendation is now to just start Ranch normally when using embedded listeners.
num_listen_socketsoption has been added. It allows opening more than one listening socket per listener. It can only be used alongside the Linux
SO_REUSEPORTsocket option or equivalent. It allows working around a bottleneck in the kernel and maximizes resource usage, leading to increased rates for accepting new connections.
socketoption was removed. A more viable solution is to define a custom transport module that returns a fresh socket when
Transport:listen/1and its implementations in
ranch_sslhave changed to accept a map of transport options instead of only socket options.
Transport:messages/0return value now include the tag used for passive messages.
Socketargument was removed from
Protocol:start_link/3. The socket must now be obtained by calling
NumAcceptorsargument was removed from
ranch:child_spec/5and moved to the transport options.
ranch:opts()map or only socket options as-is. Individual transport options are now validated as well. The
ranch:opts()map must be used when socket options also use a map. This applies to the
ranch:info/1,2now returns a map containing each listener's information rather than a list of key/values. The key
num_acceptorswas removed as it can be found in the transport options.
ranch:set_transport_options/2no longer requires the listener to be suspended. Which options apply immediately, on suspend/resume or on restart has been documented. Some work has also been done to make these option changes more predictable.
ranch:accept_ack/1has been removed in favor of
ranch:remove_connection/1from a connection process would crash the respective connection supervisor. This has now been fixed.
havoc, a chaos monkey style testing tool. Currently includes three scenarios: normal TCP and TLS listeners and embedded TCP listener. This new test suite helped uncover a misplaced
monitor/2call added during the development of Ranch 2.0.
1 + ceil(math:log2(NumChildren))to allow room for errors when they have many children.
ranch_ssl:ssl_opt()type has been updated to conform with Erlang/OTP 22.0.
Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:
Recurring payment options are also available via BountySource. These funds are used to cover the recurring expenses like dedicated servers or domain names.