11

The mainline Bitcoin client limits number of outbound connections to 8 however allows up to 125 total connections. To achieve greater than 8 connections (due to outbound limitation) requires either using uPnp or port forwarding so that the client can accept inbound connections.

Why is there a limit of 8 connection and only on outbound connections? Why not allow the client to create 20 or 125 outbound connections?

3 Answers 3

8

This is a legacy issue.

When the network was first implemented, there was a severe shortage of servers that could reliably accept inbound connections. Many people started running the client behind NAT and they could not accept any inbound connections. Meanwhile, they were consuming the available inbound connection capacity of the more limited number of machines that could accept them. The client now enables uPNP traversal by default.

Second, there were problems with the client code that caused it not to be able to support as many connections as it should have been able to. Many nodes could not even support the default 125 connections, even though their CPU and network usage was nowhere near maxed.

These days, it's just kind of stuck. My 'hub mode' patches make it easily possible for clients to support 1,500 connections. But they almost never see more than 200 clients because the network capacity limitations are long gone.

You need a healthy number of outbound connections because a malicious adversary can consume all your inbound connection slots by repeatedly connecting to you, and staying connected, from a variety of IP addresses. The Bitcoin client actually has code to try to get IP diversity in its outbound connections to protect against some entity creating a million servers and having a high chance of getting all 8 of your outbound slots.

If you're paranoid, turn this up. You can still configure for 32 outbound connections if you can also add at least 64 inbound connection slots in exchange. You'll be helping the network. You can use my hub mode patches to do this.

2
  • Thanks. So why haven't the developers increased the limit in mainline client? One would think with each version they would make some adjustments. Looking at the newbie section on Bitcointalk forum the slow and inconsistent performance downloading blockchain is a continual problem. As the block chain gets no longer the 8 connection limits appear at least to me to be more and more archaic. At least bumping it to 16 would allow higher throughput for new clients. Commented Nov 13, 2011 at 2:06
  • I think the slow block sync rate is due to two issues, neither of which are related to the connection limit. One was a bug that was fixed but older clients still mess up newer ones. The other is the fact that the client validates every block, every hash, and every transaction. There are over 100,000 blocks and typical PCs can't validate more than about 15 per second. Commented Nov 13, 2011 at 2:09
2

Bitcoin client that accepts inbound connections, lets call it server, can accept a limited number of them. Assuming number of clients is greater then number of servers, if clients have no heavy restrictions on number of outbound connections, then it would overload servers and deny access to blockchain data to some clients.

To illustrate, imagine situation where there is only one server on the network and many bitcoin clients, if clients can reserve as many server connections as they want that would for sure prevent some clients from connecting to the server.

1

the constants to set numbers of connections are in src/net.h

static const int MAX_OUTBOUND_CONNECTIONS = 8;

in the repo on github: https://github.com/bitcoin/bitcoin/blob/3bf06e9bac57b5b5a746677b75e297a7b154bdbd/src/net.h#L59

change to what you like and recompile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.