Number of connections

Kyle

New member
what is the best number of connections today?

I discovered a setting: "maxconnections" inside bitcoin.conf / bitcoind -help also.

I tried 2000 but at startup, I get a message that a maximum of 845 by hardware limitations is only possible.
 

Diego

Member
what is the best number of connections today?

I discovered a setting: "maxconnections" inside bitcoin.conf / bitcoind -help also.

I tried 2000 but at startup, I get a message that a maximum of 845 by hardware limitations is only possible.
even if this is a very old thread you pumed up
Smiley

Nice to read Satoshi.

To answer: The limitation is based on the file descriptors on your system:
nMaxConnections = std::min(nFD - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS, nMaxConnections);

so if you can tune your OS you can do more than your 845.
look here the warning from Pieter Wuilli: https://bitcoin.stackexchange.com/q...00-connections-like-blockchain-info/8140#8140
 

Cole

Member
While we are at it, Can someone tell me the effect of setting maxconnections=1? Does it become half duplex or something?
 

Ahmir

Member
While we are at it, Can someone tell me the effect of setting maxconnections=1? Does it become half duplex or something?
If you set maxconnections=9 (8+1) then you are allowing a maximum of only 1 incoming connection to connect to your node. This won't save your RAM memory if you are thinking so. Reducing the incoming connections to 1 would reduce the usage of RAM to just few kb. Setting up the incoming connections to very low is similar to not allowing anyone to download your content even though you are seeding a file after successfully downloading it. As per Gavin's reddit post if you are limiting your incoming connections to a very low value (say 1) you are probably not helping the community by running a full node. Then there is no need for running a full node after all if you are not allowing anyone to connect to you.

Setting up your maxconnections to insane levels like OP is also not a good idea. You are thinking of contributing to the network rather you are destroying your own PC by overloading them. If you really need to connect to more connections then you could manually increase your file descriptors by using the ulimit command.
 

Maxwell

Member
While we are at it, Can someone tell me the effect of setting maxconnections=1? Does it become half duplex or something?
If you set maxconnections=9 (8+1) then you are allowing a maximum of only 1 incoming connection to connect to your node. This won't save your RAM memory if you are thinking so. Reducing the incoming connections to 1 would reduce the usage of RAM to just few kb. Setting up the incoming connections to very low is similar to not allowing anyone to download your content even though you are seeding a file after successfully downloading it. As per Gavin's reddit post if you are limiting your incoming connections to a very low value (say 1) you are probably not helping the community by running a full node. Then there is no need for running a full node after all if you are not allowing anyone to connect to you.

Setting up your maxconnections to insane levels like OP is also not a good idea. You are thinking of contributing to the network rather you are destroying your own PC by overloading them. If you really need to connect to more connections then you could manually increase your file descriptors by using the ulimit command.
The comment in bitcoin.conf says:

# Maximum number of inbound+outbound connections.

This is why i am confused about the value 1.

Now for bigger values, does it pick half for inbound and half for outbound, or something else? Ie. does the value 2 means: 1 in, 1 out? Or it could be 2 in only, later 2 out only, later 1 in 1 out?

If there were separate values for IN and OUT it would be more clear to me, but you are saying this means INcoming only?
 

Ivan

Member
While we are at it, Can someone tell me the effect of setting maxconnections=1? Does it become half duplex or something?
I think it fills outbound slots first, certainly if a node is catching up then inbound slots do not get negotiated until catch up to the chain tip is complete.
 

Kingston

Member
This is why i am confused about the value 1.
If there were separate values for IN and OUT it would be more clear to me, but you are saying this means INcoming only?
I have misread your earlier post. I thought you were asking about setting up 1 connection higher than the default 8 connections. Note that, you are a full node only if you have at least 8 active connections. Setting that to 1 doesn't make sense actually and the qt wallet wouldn't function as a full node if you are just connected to only one other node. Having 8 or lesser connections is considered bad to the network and you are overloading the bitcoin network unnecessarily in the name of running a node.
Maximum number of inbound+outbound connections
Yes that's true, the maxconnections is the sum of outbound connections (which is by default 8 and would probably get connected as soon as your client is ready) and inbound connections. With maxconnections you can control the incoming/inbound connections as the outbound would be fixed to 8 always.
Now for bigger values, does it pick half for inbound and half for outbound, or something else? Ie. does the value 2 means: 1 in, 1 out? Or it could be 2 in only, later 2 out only, later 1 in 1 out?
The bitcoin protocol would function similar to downloading a file via torrent. You first connect to other nodes (outbound) and get the information and would seed(inbound) the information for other nodes once you have got that.
 

Ashton

Member
Hmm so if i specify maxconnections=1 this means i have 8 OUT and 1 IN correct?
NO, you are making this more complex! If you just specify maxconnections=1 it wouldn't make any sense at all, what I thought was you were adding just 1 connection apart from the minimum 8 connections. If your node connects to only 1 other node connection it doesn't function as a full node at all and you are doing more bad to the network
But if i query bitcoind (also written in the wiki) it shows this:

So where did your 8 come from?
As the above user said, 8 is the maximum outbound connections. Whenever you start your client and it gets synced to blocks, it gets connected to 8 other nodes. I assume this is also the minimum one, as suggested in git, wiki and in this forum. Probably you shouldn't change the maxconnections, since connecting to maximum nodes is considered healthy for the network and would be fair for bitcoin to work in a trustless way.
Other coin wallets based on core such as dogecoin-qt and litecoin-qt wouldn't allow you to connect less than 8 connections. I assume that is the same for bitcoin too.

P.S I am not aware how TOR node functions and edited my previous post for better understanding
 

Kaiden

Member
Leaving it undefined (commented out) bitcoind outputs (and logs) this:
Using at most 125 automatic connections (1024 file descriptors available)

If 1 (either bitcoin.conf or -maxconnections=1, it shows this:
Using at most 1 automatic connections (1024 file descriptors available)

Using "2000" like the OP wanted, it shows this:
Using at most 865 automatic connections (1024 file descriptors available)

So to clarify, this value means: How many nodes i let connect to me, while I'm always connected to 8 nodes regardless?
 

Giovanni

Member
So to clarify, this value means: How many nodes i let connect to me, while I'm always connected to 8 nodes regardless?
Could you please be more clear in framing your question? I can't get your point clearly, but based on my understanding you seem to ask how many incoming connections you allow apart from the 8 outgoing connections if you have specified those above mentioned values?

If so,
Leaving it undefined (commented out) bitcoind outputs (and logs) this:
Using at most 125 automatic connections (1024 file descriptors available)
While you are specifying maxconnections at default, you allow at most 117 incoming connections to connect to you and 8 outgoing connections are by default connected from your node.
If 1 (either bitcoin.conf or -maxconnections=1, it shows this:
Using at most 1 automatic connections (1024 file descriptors available)
While you are specifying maxconnections to 1, your node doesn't function as a full node and I am tired of answering this. You cannot do that/ probably it's useless to run a full node dude if you are having maxconnections set to 1.
Using "2000" like the OP wanted, it shows this:
Using at most 865 automatic connections (1024 file descriptors available)
Your node would be connected to 8 connections and you allow at most 857 incoming connections to connect to your node. By this way, you would receive transaction information if any of those 857 connections broadcast them and vice versa.

So, if your next question is "How can I increase the 8 outbound connections to a higher limit?"

They are hard-coded in the net.h of the client code.

Code:
/** Maximum number of outgoing nodes */
static const int MAX_OUTBOUND_CONNECTIONS = 8;

Change that to whatever higher limit you need and fork out or create a PR in git and see that if it gets accepted by the community. (This has been suggested many a times but those are not to be changed and put even more load on the declining nodes).
 

Jesus

Member
So, if your next question is "How can I increase the 8 outbound connections to a higher limit?"

They are hard-coded in the net.h of the client code.

Code:
/** Maximum number of outgoing nodes */
static const int MAX_OUTBOUND_CONNECTIONS = 8;

Change that to whatever higher limit you need and fork out or create a PR in git and see that if it gets accepted by the community. (This has been suggested many a times but those are not to be changed and put even more load on the declining nodes).
I would strongly deter doing the above, and so would many others.


That's bad for the network in principle, network-wide inbound connection slots are a resource that shouldn't be used unnecessarily. And there is no reason to use more outbound connections than are needed to sync the chain.

If you want to improve the network, then contribute incoming connections so that more people can join. i.e. open a port and get your bitcoin node to listen for other nodes on that port. Editing the hardcoded maximum outbounds is essentially the opposite; occupying other nodes incoming slots over and above what a single node needs, limiting the network instead of expanding it.
 

Calvin

Member
Could you please be more clear in framing your question? I can't get your point clearly, but based on my understanding you seem to ask how many incoming connections you allow apart from the 8 outgoing connections if you have specified those above mentioned values?
You have already partially answered my question, but this detail eludes me:
While you are specifying maxconnections at default, you allow at most 117 incoming connections to connect to you and 8 outgoing connections are by default connected from your node.
Here you subtract 8 from the default 125, resulting in 117. With the 865 example you subtract 8 again so, 857. Fine and easy to understand. Now the problem lies with the value 8 or less...

What does maxconnections=8 means? 0 incoming? then what does any value under 8 means? Leaving the fact that "its not a full node", though I wonder how do you call a node like that then?

bitcoind -maxconnections=8
Using at most 8 automatic connections (1024 file descriptors available)

If the maxconnections value just means the number of incoming, as i was understanding from other posters, it would mean that the default of 125 would be 125+8 instead of 125-8. Then it makes perfect sense, i could use maxconnections=4 and that would be 4+8. I now see that the value 8 is hardcoded for outgoing connections (unless you edit the code and recompile), so you can only manipulate incoming by maxconnections.

bitcoind -maxconnections=4
Using at most 4 automatic connections (1024 file descriptors available)

If this is not a full node, what it is? What are nodes using values 1~8 for maxconnections?
 
Top