aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/operations.md30
-rw-r--r--docs/transports.md27
2 files changed, 57 insertions, 0 deletions
diff --git a/docs/operations.md b/docs/operations.md
index 0777c52..e3355e5 100644
--- a/docs/operations.md
+++ b/docs/operations.md
@@ -331,6 +331,36 @@ And from the log, at warn or error:
* `Peer speaks another wire version: …; ignoring its messages`: a node on another
build; the message names both versions, and whether to upgrade this node or that one.
+## An idle node
+
+A node that nothing is written to still wakes: for its keepalives (`--keepalive`, two
+per neighbour and interval), for what it checks once a minute (its entry in the member
+list, whom it reaches, its clock against its peers'), and for its transports' own
+timers. Each time, some of its threads wake. On a machine that should sleep between
+those (a laptop, a small server that does other things), two options make it less:
+
+* **`--worker-threads COUNT`**: how many threads take the node's work in turns. As
+ many as the machine has cores unless given; whatever wakes the node may wake several
+ of them, as they hand work to each other. What takes long (reading and saving the
+ document, judging a store's events, a remake's snapshot) runs on threads of its own
+ beside them, started as needed and ended when idle, so few worker threads don't make
+ those wait. The count is set as the node starts: a restart changes it.
+ * **2** suits most nodes: a member of a swarm with little writing, on a machine with
+ other work.
+ * **The default** suits a node that serves many API clients or streams at once, or
+ relays for many peers: there, more threads take more at a time.
+ * **1** works, but one piece of work that takes long holds up everything else,
+ keepalives among it: not below 2 without a reason.
+* **`--libp2p-ping-interval DURATION`**: how often libp2p pings each connection; `0`
+ for once only ([`transports.md`](transports.md), [Pings](transports.md#pings)).
+
+Measured here, three nodes on one machine of 12 cores over libp2p (TCP), nothing
+written, each node's thread wakeups a second over a minute and a half: 4 to 6 as
+shipped; 3 to 5 with two worker threads or without pings; 2 to 3 with both. The
+figures move from one minute to the next, so take them for their order, not their
+digits. `top -H -p PID` shows the threads (`tokio-rt-worker`, and `futures-timer`,
+libp2p's), and `/proc/PID/task/*/status` their `voluntary_ctxt_switches`.
+
## What a node uses
* **Memory**: the document with its history (Automerge holds more in memory than
diff --git a/docs/transports.md b/docs/transports.md
index 2b1b07e..b3a01b7 100644
--- a/docs/transports.md
+++ b/docs/transports.md
@@ -244,6 +244,33 @@ traffic for long. It also makes the node's peer ID and addresses known to the DH
to anyone. Without it, nothing public is used. (For Mycelium, public peers are in
`--mycelium-peers`: none unless given.)
+### Pings
+
+libp2p pings every open connection, once as it opens and then every
+`--libp2p-ping-interval` (15 s unless given; `0` for never again). continuum uses the
+pings for one thing: the round trip of each connection, by which it keeps the fastest
+of several to one peer, the shortest each measured counting. They keep no connection
+open and close none: a connection nobody uses for five minutes, or for three
+`--keepalive` intervals where that is longer, is closed whatever was pinged, and whether a
+peer answers is told by continuum's own keepalives, on whatever transport. Other
+libp2p nodes' pings are answered whatever the interval.
+
+So a longer interval, or none, costs only how well a connection's round trip is known
+after its first ping: a first ping that came back late (a busy moment) is not put
+right by a later one, and the slower of two connections may be kept. What it spares
+is a wakeup of the node per connection and interval, and over TCP the pings of the
+stream multiplexer (Yamux), which measures its own round trip only while a connection
+is used. QUIC keeps its connections open by itself, every few seconds, whatever this
+says.
+
+* **Leave it at 15 s** where round trips matter and vary: nodes with several paths to
+ each other of different speed (a LAN and a relay, ethernet and WLAN) that come and
+ go.
+* **A few minutes** (`5m`) is a middle: the round trip is put right within that time.
+* **`0`** on nodes that reach each other one way (servers at fixed addresses), and
+ wherever a machine should be left idle
+ ([`operations.md`](operations.md), [An idle node](operations.md#an-idle-node)).
+
### On the LAN
With `--libp2p-mdns`, a node finds libp2p peers on its LAN (multicast DNS, IPv4): it