-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
Affects Version/s: None
-
Labels:
The docs for 3.0 incorrectly state that the default value of maxIncomingConnections is 65536. This is based on DOCS-5026, however that ticket is wrong on two levels, and should be reverted.
- The default value in the code is 1000000, the same as in 2.6:
src/mongo/util/net/listen.h 46: const int DEFAULT_MAX_CONN = 1000000;
maxIncomingConnections is simply an upper bound that the server applies, in addition to anything the OS might do. Any other upper bounds that might happen to be imposed by any given system/environment/transport are irrelevant for the maxIncomingConnections server option. (At most, they could be noted, but certainly the default server config value should not be misdocumented because of them.)
- TCP has no limit of 65536 incoming connections to a single destination port. Even if it did, Unix Domain Sockets (UDS), which are a valid transport to use in some cases, have no notoin of "ports" and so no such limit. Perhaps this has been confused with the maximum number of source (aka ephemeral) ports that can be used for outgoing connections?
Since the "TCP is limited to 64k ports" notion is a common misconception, I have proven it to be false empirically by creating ~126k TCP connections to a standalone mongod. The logfile is attached.2015-04-10T04:26:58.296+0000 I NETWORK [initandlisten] connection accepted from 172.31.2.238:28517 #127009 (126802 connections now open)
This isn't easy — you need more than 1 client host connecting to the server, and there are a whole raft of settings that have to be fiddled with (on both the server and client hosts), but it's certainly possible. The client hosts only need to do something like
a = []; for (i=0; i<100000;i++) a.push(connect("172.31.19.134:27017/test"))
in a mongo --nodb shell. In fact if you look carefully in the logs you'll see where the clients stop connecting for a while. This is because they ran out of ephemeral ports, which is by default 32768-61000 on Linux, and I had to increase it to 1-65535 and start the mongo shells connecting again.
In the past I have managed to get to ~586k connections (using Unix Domain Sockets, because it was easier) before the medium-sized host crashed outright.
- related to
-
DOCS-5026 Fix 1MM net.maxIncomingConnections
- Closed