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 -
To turn the behavior on at startup in a 2.4 mongos (this is not available before 2.4), you can also use: