|
2 | 2 | description: Managing Hyperledger Besu peers |
3 | 3 | --- |
4 | 4 |
|
5 | | -# Managing peers |
| 5 | +# Manage peers |
6 | 6 |
|
7 | | -## Limiting peers |
| 7 | +Hyperledger Besu peer-to-peer (P2P) discovery happens periodically based on the number of peers in a network and the |
| 8 | +node's [peer limit](#limit-peers). |
8 | 9 |
|
9 | | -Limiting peers reduces the bandwidth used by Hyperledger Besu. Limiting peers also reduces the CPU |
10 | | -time and disk access used to manage and respond to peers. |
| 10 | +The frequency of discovery isn't configurable, but you can [limit remote connections](#limit-remote-connections) in |
| 11 | +public networks and [randomly prioritize connections](../../Reference/CLI/CLI-Syntax.md#random-peer-priority-enabled) |
| 12 | +in small, stable networks. |
| 13 | + |
| 14 | +!!! info |
| 15 | + |
| 16 | + You can use [`admin_addPeer`](../../Reference/API-Methods.md#admin_addpeer) to attempt a specific connection, but |
| 17 | + this isn't P2P discovery. |
| 18 | + |
| 19 | +We recommend [using bootnodes](Bootnodes.md) to initially discover peers. |
| 20 | + |
| 21 | +## Limit peers |
| 22 | + |
| 23 | +You can limit peers to reduce the bandwidth, CPU time, and disk access Besu uses to manage and respond to peers. |
11 | 24 |
|
12 | 25 | To reduce the maximum number of peers, use the |
13 | 26 | [`--max-peers`](../../Reference/CLI/CLI-Syntax.md#max-peers) option. The default is 25. |
14 | 27 |
|
15 | | -## No discovery |
| 28 | +## Limit remote connections |
16 | 29 |
|
17 | | -To disable P2P discovery, use the |
18 | | -[`--discovery-enabled`](../../Reference/CLI/CLI-Syntax.md#discovery-enabled) option. |
| 30 | +Prevent eclipse attacks when using [`--sync-mode`](../../Reference/CLI/CLI-Syntax.md#sync-mode) and |
| 31 | +[`--fast-sync-min-peers`](../../Reference/CLI/CLI-Syntax.md#fast-sync-min-peers) on public networks by enabling the |
| 32 | +[remote connection limits](../../Reference/CLI/CLI-Syntax.md#remote-connections-limit-enabled). |
19 | 33 |
|
20 | | -With discovery disabled, peers that have already discovered or are otherwise configured to connect |
21 | | -to the local node (for example, using |
22 | | -[`admin_addPeer`](../../Reference/API-Methods.md#admin_addpeer)) can open connections. |
23 | | -[Static nodes](Static-Nodes.md) can also open connections. |
| 34 | +In private and permissioned networks with only trusted peers, enabling the remote connection limits is |
| 35 | +unnecessary and might adversely affect the speed at which nodes can join the network. |
| 36 | +Limiting remote connections can cause a closed group of peers to form when the number of nodes in the network is |
| 37 | +slightly higher than [`--max-peers`](../../Reference/CLI/CLI-Syntax.md#max-peers). |
| 38 | +The nodes in this closed group are all connected to each other and can't accept more connections. |
| 39 | + |
| 40 | +!!! tip |
| 41 | + |
| 42 | + You can use [`--random-peer-priority-enabled`](../../Reference/CLI/CLI-Syntax.md#random-peer-priority-enabled) to |
| 43 | + help prevent closed groups of peers in small, stable networks. |
24 | 44 |
|
25 | | -## Monitoring peer connections |
| 45 | +## Monitor peer connections |
26 | 46 |
|
27 | 47 | JSON-RPC API methods to monitor peer connections include: |
28 | 48 |
|
29 | | -* [`net_peerCount`](../../Reference/API-Methods.md#net_peercount) |
30 | | -* [`admin_peers`](../../Reference/API-Methods.md#admin_peers) |
| 49 | +* [`net_peerCount`](../../Reference/API-Methods.md#net_peercount). |
| 50 | +* [`admin_peers`](../../Reference/API-Methods.md#admin_peers). |
31 | 51 | * [`debug_metrics`](../../Reference/API-Methods.md#debug_metrics). |
32 | 52 |
|
33 | 53 | Each peer entry returned by [`admin_peers`](../../Reference/API-Methods.md#admin_peers) includes a |
34 | 54 | `protocols` section. Use the information in the `protocols` section to: |
35 | 55 |
|
36 | | -* Determine health of peers. For example, an external process could use [`admin_peers`](../../Reference/API-Methods.md#admin_peers) |
37 | | -and [`admin_removePeer`](../../Reference/API-Methods.md#admin_removepeer) to disconnect from peers that |
38 | | -are stalled at a single difficulty for an extended period of time. |
| 56 | +* Determine the health of peers. |
| 57 | + For example, an external process can use [`admin_peers`](../../Reference/API-Methods.md#admin_peers) and |
| 58 | + [`admin_removePeer`](../../Reference/API-Methods.md#admin_removepeer) to disconnect from peers that are stalled at a |
| 59 | + single difficulty for an extended period of time. |
39 | 60 |
|
40 | | -* Monitor node health. For example, if peers are reporting increasing difficulties but node |
41 | | -is stuck at the same block number, the node may be on a different fork to most peers. |
| 61 | +* Monitor node health. |
| 62 | + For example, if peers report increasing difficulties but the node is stuck at the same block number, the node may be |
| 63 | + on a different fork to most peers. |
42 | 64 |
|
43 | | -* Determine which protocol level peers are communicating with. For example, to see if `"version": 65` |
44 | | -is being used to reduce transaction sharing traffic. |
| 65 | +* Determine which protocol level peers are communicating with. |
| 66 | + For example, you can see if `"version": 65` is being used to reduce transaction sharing traffic. |
45 | 67 |
|
46 | | -## Node connections |
| 68 | +## List node connections |
47 | 69 |
|
48 | | -The default logging configuration does not list node connection and disconnection messages. |
| 70 | +The default logging configuration doesn't list node connection and disconnection messages. |
| 71 | +To enable listing them, set the [`--logging`](../../Reference/CLI/CLI-Syntax.md#logging) option to `DEBUG`. |
| 72 | +For more verbosity, set the option to `TRACE`. |
49 | 73 |
|
50 | | -To enable listing of node connection and disconnection messages, specify the |
51 | | -[`--logging`](../../Reference/CLI/CLI-Syntax.md#logging) option `--logging=DEBUG`. For more |
52 | | -verbosity, specify `--logging=TRACE`. |
53 | | - |
54 | | -The console logs connection and disconnection events when the log level is `DEBUG` or higher. If |
55 | | -the message `Successfully accepted connection from ...` displays, connections are getting through |
56 | | -the firewalls. |
| 74 | +The console logs connection and disconnection events when the log level is `DEBUG` or higher. |
| 75 | +If the message `Successfully accepted connection from ...` displays, connections are getting through the firewalls. |
57 | 76 |
|
58 | 77 | !!! example "Sample log output" |
59 | 78 |
|
60 | | - `2018-10-16 12:37:35.479-04:00 | nioEventLoopGroup-3-1 | INFO | NettyP2PNetwork | Successfully accepted connection from 0xa979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c` |
| 79 | + ```bash |
| 80 | + 2018-10-16 12:37:35.479-04:00 | nioEventLoopGroup-3-1 | INFO | NettyP2PNetwork | Successfully accepted connection from 0xa979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c |
| 81 | + ``` |
61 | 82 |
|
62 | | -## Limiting remote connections |
| 83 | +## Disable discovery |
63 | 84 |
|
64 | | -In private and permissioned networks with a level of trust between peers, enabling the |
65 | | -[remote connection limits](../../Reference/CLI/CLI-Syntax.md#remote-connections-limit-enabled) |
66 | | -is unnecessary and might adversely affect the speed at which nodes can join the network. |
67 | | -Limiting remote connections may cause a clique of nodes to form when the number of nodes in the network is slightly |
68 | | -higher than [`--max-peers`](../../Reference/CLI/CLI-Syntax.md#max-peers). |
69 | | -The nodes in this clique are all connected to each other and cannot accept more connections. |
| 85 | +To disable P2P discovery, set the |
| 86 | +[`--discovery-enabled`](../../Reference/CLI/CLI-Syntax.md#discovery-enabled) option to `false`. |
70 | 87 |
|
71 | | -In public networks, enabling the remote connections limit is necessary to prevent eclipse attacks, especially when |
72 | | -using [`--sync-mode`](../../Reference/CLI/CLI-Syntax.md#sync-mode) and |
73 | | -[`--fast-sync-min-peers`](../../Reference/CLI/CLI-Syntax.md#fast-sync-min-peers). |
| 88 | +With discovery disabled, peers can't open connections with the node unless they were previously discovered or manually |
| 89 | +peered (for example, using [`admin_addPeer`](../../Reference/API-Methods.md#admin_addpeer)). |
| 90 | +[Static nodes](Static-Nodes.md) can also open connections. |
0 commit comments