Is mongos -> mongod connection timeout configurable?

111 views
Skip to first unread message

Peter Ivanov

unread,
Sep 14, 2017, 8:59:37 PM9/14/17
to mongodb-user
Hi, 

We're using mongo 3.4 and have recently started to use mongos in production environment. 
One of the issues it introduced looks like this. We use go mongo driver with socket timeout configured, so if a requests takes too long, a connection is closed. If there is a lot of timeouts, then of course mongod still processes some extra requests, but at least the number of incoming connections is limited to (number of client nodes)*(mongo connection pool size on each node).
Now, with mongos we observed that when a 'client -> mongos' connection is closed, a 'mongos -> mongod' connection remains open. So, with new requests following the ones that timed out, the number of open connections to mongod nodes spiked. That's bad. 

It there a common way to combat this effect?
As far as I understand, it is a common practice to use timeouts on mongo clients, so this issue must be common as well.
There is a '--maxConns' setting for mongos, but this applies for incoming connections, so if those a closed by a client, this limit seems not to be the remedy.
As for connection timeout in mongos itself, all I could find was a TCP keepalive timeout which is <= 5 minutes and does not seem to be configurable, not to mention that TCP keepalive seems like a wrong way of dealing with the issue. (https://docs.mongodb.com/v3.4/faq/diagnostics/#does-tcp-keepalive-time-affect-mongodb-deployments)

The only client-side solution I can think of is not to close connections in case of a timeout, but this requires some heavy meddling with mongo driver, so I'd really like to avoid it if I can. 
Any insight on the subject will be much appreciated. 

Weishan Ang

unread,
Sep 15, 2017, 8:24:21 PM9/15/17
to mongodb-user
we are currently using tcp keepalive to keep connections between mongos to mongod alive. Why is it the wrong way?

Peter Ivanov

unread,
Sep 17, 2017, 9:02:41 AM9/17/17
to mongodb-user
Because it's not keeping them alive that I'm talking about, it's making them time out or close when the incoming connection to mongos is closed.

суббота, 16 сентября 2017 г., 3:24:21 UTC+3 пользователь Weishan Ang написал:

Kevin Adistambha

unread,
Oct 5, 2017, 9:28:36 PM10/5/17
to mongodb-user

Hi Peter

Does this ticket describe what you need? https://jira.mongodb.org/browse/SERVER-19410

If that’s the correct scenario, I would suggest you to comment/upvote on the ticket describing your use case so it’s clearer why this feature is needed.

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages