Skip to content

Commit 4d205e5

Browse files
authored
advanced: Number of connections (#803)
For syncthing/syncthing#8918.
1 parent 5646e04 commit 4d205e5

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

advanced/device-numconnections.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
numConnections
2+
==============
3+
4+
.. versionadded:: 1.25.0
5+
6+
``numConnections`` is a device setting that affects connection handling. A
7+
zero value means to use the Syncthing default. As of version 1.25.0 the
8+
default is to use one connection, like earlier versions of Syncthing. This
9+
may change in the future.
10+
11+
Multiple connections will be maintained to the device if you set this to a
12+
value greater than one. Multiple connections can yield improved performance
13+
by load-balancing traffic over multiple physical links or in other
14+
scenarios.
15+
16+
A simple form of negotiation is used to decide how many connections to use
17+
between a device pair. It goes like this:
18+
19+
- If either side is configured to use a single connection, then a single
20+
connection is used. Since the default is to use a single connection this
21+
means that to use more than one connection both sides must be configured
22+
to do so.
23+
- If both sides are configured to use multiple connections, then the larger
24+
of the two values is used. That is, if one side is configured to use three
25+
connections and the other is set to use eight connections, eight
26+
connections will be used.
27+
- A maximum of 128 connections will be used under all circumstances. It is
28+
likely that the "return on investment" in further connections is
29+
negligible above about 10 to 20 connections, so this limit should be
30+
sufficient for all realistic use cases.
31+
32+
.. note::
33+
34+
Additional connections are established over time, roughly at the rate of
35+
one per minute when Syncthing is in a steady state, so you may not see
36+
the expected number of connections immediately after changing this
37+
setting.
38+
39+
Load Balancing
40+
--------------
41+
42+
When there are multiple connections between two devices, one connection is
43+
dedicated to metadata transmission: index updates, changes to folder pause
44+
status, etc. Requests and responses are sent over the other connections
45+
randomly. The number of connections in the GUI is represented as `1 + n` for
46+
this reason, e.g. if you configure four connections, the GUI will show `1 +
47+
3` to indicate one metadata connection and three data connections.
48+
49+
Rate Limiting
50+
-------------
51+
52+
Device rate limiting applies to the sum of traffic on all connections,
53+
regardless of the number of connections. The limit is not per connection.
54+
55+
Connection Types
56+
----------------
57+
58+
Both TCP and QUIC connections are supported for multiple connections.
59+
Syncthing will, however, only keep connections with the best priority; by
60+
default, TCP has better priority than QUIC, so establishing a TCP connection
61+
will cause existing QUIC connections to be closed. Connection priorities can
62+
be configured.
63+
64+
Multiple connections cannot be established over relays.

users/config.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ Device Element
620620
<maxRequestKiB>0</maxRequestKiB>
621621
<untrusted>false</untrusted>
622622
<remoteGUIPort>0</remoteGUIPort>
623+
<numConnections>0</numConnections>
623624
</device>
624625
<device id="2CYF2WQ-AKZO2QZ-JAKWLYD-AGHMQUM-BGXUOIS-GYILW34-HJG3DUK-LRRYQAR" name="syno local" compression="metadata" introducer="true" skipIntroductionRemovals="false" introducedBy="">
625626
<address>tcp://192.0.2.1:22001</address>
@@ -631,6 +632,7 @@ Device Element
631632
<maxRequestKiB>65536</maxRequestKiB>
632633
<untrusted>false</untrusted>
633634
<remoteGUIPort>8384</remoteGUIPort>
635+
<numConnections>0</numConnections>
634636
</device>
635637
636638
One or more ``device`` elements must be present in the file. Each element
@@ -796,6 +798,11 @@ From the following child elements at least one ``address`` child must exist.
796798
"receive encrypted" type locally. Refer to the detailed explanation under
797799
:doc:`untrusted`.
798800

801+
.. option:: device.numConnections
802+
803+
The number of connections to this device. See
804+
:doc:`/advanced/device-numconnections` for more information.
805+
799806

800807
GUI Element
801808
-----------
@@ -1338,6 +1345,7 @@ Defaults Element
13381345
<maxRequestKiB>0</maxRequestKiB>
13391346
<untrusted>false</untrusted>
13401347
<remoteGUIPort>0</remoteGUIPort>
1348+
<numConnections>0</numConnections>
13411349
</device>
13421350
<ignores>
13431351
<line>!foo2</line>

users/tuning.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ These options are folder specific and should be set on each folder:
122122
Use these if they are required for your use case, but keep in mind they
123123
have a fairly high performance cost.
124124

125+
For devices, consider the following:
126+
127+
- :opt:`numConnections`
128+
Set at or above the number of CPU cores available. This allows maximum
129+
concurrency for TLS connections and may improve performance.
130+
125131
Other things:
126132

127133
- ``GOMEMLIMIT`` and ``GOGC``: These environment variables can be used to
@@ -188,6 +194,12 @@ Folders options:
188194
cause data loss if your underlying filesystem is *not* in fact case
189195
sensitive.
190196

197+
Device options:
198+
199+
- :opt:`numConnections`
200+
Set to 1 to reduce the amount of overhead per device, as each connection
201+
has a memory and CPU cost.
202+
191203
Other things:
192204

193205
- ``GOMEMLIMIT`` and ``GOGC``

0 commit comments

Comments
 (0)