summaryrefslogtreecommitdiffstats
path: root/_build/content/articles/ranch-2.0.0.asciidoc
blob: 82a0e168736218df44af67fe8176ebc163b1486e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
+++
date = "2020-06-25T07:00:00+01:00"
title = "Ranch 2.0"

+++

Ranch `2.0.0` has been released!

In Ranch 1.x, there is only one supervisor per Ranch listener
to start and manage connection processes. Under high load
(many clients rapidly connecting and/or disconnecting), the
message queue of this one supervisor could become congested,
leading to declining accept rates or a stalled listener.

Ranch 2.0 introduces the `num_conns_sups` option (defaulting
to the number of acceptors), which allows the message load to
be divided between the specified number of connection supervisors.
This improves accept concurrency at the same time.

Another bottleneck is a possible congestion of the syn queue of
a listening socket. The reason is located within the operating
system's TCP/IP implementation, and on Linux the `SO_REUSEPORT`
socket option was introduced to address it. What it boils down
to is that you can have more than one socket listening on
the same port, causing the sockets to be "load-balanced" when
accepting connections.

Ranch 2.0 introduces the `num_listen_sockets` option, which allows
to specify the number of listening sockets a Ranch listener should
employ. Whether you can use `SO_REUSEPORT` at all and how to enable
it depends on your operating system, though.

Other changes include proper support for local (Unix Domain) sockets,
removing the restriction that a listener be suspended to change its
transport options and much needed improvements to embedded listeners.

In addition we have had patches merged to Erlang/OTP to add support
for active N to the `ssl` application (requires Erlang/OTP 21.3 or
above) and fix a number of smaller issues we encountered. We have
also helped detect and fix a bug in the Windows implementation of
active N that greatly reduced its performance in some cases.

To ensure that everything works correctly, new tests have been
written, and some existing tests were updated. Ranch is now tested
against https://github.com/juhlig/stampede[Stampede], a resilience
testing tool that kills random processes and ports in the system;
and against https://concuerror.com/[Concuerror], a model checking
tool for debugging, testing and verifying concurrrent Erlang programs.

Starting from Ranch 2.0 onward, a `.appup` file is provided and
release upgrades are tested and supported. The current plan is
to test upgrades from one version to the next.

We are now providing a
https://github.com/juhlig/prometheus_ranch[Prometheus collector]
as a separate project as well as a
https://github.com/juhlig/prometheus_ranch/blob/master/dashboards/ranch-dashboard.json[Grafana dashboard].

Huge thanks to Jan Uhlig for working on many of the changes
and improvements that went into this release.

Ranch 2.0 requires Erlang/OTP 21 or above and is tested and supported
on Linux, FreeBSD, macOS and Windows.

A complete list of changes can be found in the migration guide:
https://ninenines.eu/docs/en/ranch/2.0/guide/migrating_from_1.7/[Migrating from Ranch 1.7 to 2.0].

You can donate to this project via
https://github.com/sponsors/essen[GitHub Sponsors].
These funds are used to pay for additional servers for
testing. We will soon add two Raspberry Pi 4 in order
to have some ARM targets when testing.

As usual, feedback is appreciated, and issues or
questions should be sent via Github tickets. Thanks!