Why is the Outbound Connection maximum only 16?

This is a question about the default connection limits in the BTG Core Full Node wallet.

A node creates 8 random outbound connections by default. In addition, you can specify a few node addresses you’d like to manually connect to, and your node will connect up to 8 of them - for a max of 16 outbound nodes. The node also has a default max of 125 connections total, which you can increase via a setting, but you cannot increase the limit of 16 on outbound connections, short of modifying the code and compiling it yourself.

The questions:

I accept that the maximum is 16 nodes - I’m just curious as to why that is the case.

It’s an attempt to balance network connectedness, safety, and privacy.

The requirement for 8 random outbound nodes makes it very difficult for a malicious attacker to isolate your node; your node has a list of peers (hundreds and hundreds of them) which it received from the nodes it has spoken to in the past. Even if an attacker tries to take up all your connections, your node will still keep trying a rotating set of random outbound nodes, always slipping out to connect to the real network. Also, 8 outbound does a very good job of creating a highly interconnected network that relays data - we know from computer science that’s it’s extremely unlikely that some nodes form an “island” disconnected from other nodes when each of them is connecting to eight random nodes. More would be better, but 8 is already quite good.

At the same time, we know that a lot of nodes do not accept inbound connections. Some have security or privacy concerns, especially in some countries. And even among those who do accept inbound, they can’t accept unlimited connections, because each additional connection consumes more resources. There must be limits. The default max for a node is 125 connections total (in + out). You can increase the maxconnections setting if you can handle even more inbound connections and want to dedicate the resources to this, but it may slow down your node (at some point, more time is spent communicating than validating or other resource constraints are hit.)

Still, my outbound is your inbound, and vice versa. If all nodes do outbound, but not all accept inbound, then the nodes that do accept inbound will have a lot of inbound connections.

What happens if not many people can accept inbound connections?

Imagine there are 1000 nodes out there which don’t accept inbound connection; each of them wants to make 8 random outbound, and sets an additional 8 intentional outbound, so that’s a total of 16000 inbound connections that have connect somewhere.

Imagine there are another 100 nodes which accept inbound connections, and they are set up at the defaults. They only make the default 8 outbound connections; that’s another 800 inbound connections that have to go somewhere, for a total of 16800. These nodes have 125 connections max, leaving 117 openings for inbound connections.

If there are only 100 nodes accepting inbound connections, and there are nodes looking for 16800 connections, that’s 168 inbound connections on each of those 100 nodes! Obviously, 168 > 117. Now, new nodes cannot join the network (or have a very hard time catching an open slot), because there are no inbound connection slots available anywhere. As Peter Wuille put it here, “connectable peers on the network are a scarce resource, and essential to the decentralization.”

And that’s the real answer to your question. Allowing too many outbound connections can make it harder for new nodes to connect, because not every node can accept inbound connections.