Create a new serverParameter for mongos, "releaseConnectionsAfterResponse," which enables returning ShardConnections from the per-socket pool to the global pool after each read operation. This should reduce the total number of outgoing mongos connections to each shard.
Warning: Enabling this option on mongos comes with the caveat that clients can only call getLastError immediately after an actual write operation. This is fine for the vast majority of use cases. However, if an application does:
- write op (no GLE)
- read op
- GLE w=2 — this will not provide any semantic guarantees (and may in fact return an unrelated error)
If your application only ever calls GLE immediately after an actual write op (which is the same as using safe mode), this option will provide a good bit of multiplexing.
The behavior is off by default. To turn the behavior on (and off) a running mongos, use the standard setParameter framework -
mongo <mongos> > use admin > db.runCommand({ setParameter : 1, releaseConnectionsAfterResponse : true }) { was : false, ok : true }
To turn the behavior on at startup in a 2.4 mongos (this is not available before 2.4), you can also use:
shell> mongos --setParameter "releaseConnectionsAfterResponse=true" --configdb ...
- duplicates
-
SERVER-8224 when lots of web server, there is too many connections
- Closed
- is related to
-
SERVER-7008 socket exception [SEND_ERROR] on Mongo Sharding
- Closed
-
SERVER-6991 Add pool stats for ShardedConnection
- Closed
- related to
-
SERVER-1714 multiplex mongos -> mongod connecions after successful read op
- Closed
-
SERVER-9055 Explicitly detect invalid gle reuse when using 'releaseConnectionsAfterResponse' mode
- Closed