, free & fully virtual. June 9th - 10th. Register Now

Connection timeout during restart

I have a replicaSet that receives two to five thousands of queries per second on each secondary node.
Connection is made by mongodb java driver, using secondaryPreferred.
Sometimes, I must do a stop/start to resize the EC2, for scale purposes.
Whenever this happens, the API shows high mongodb latency, several connection timeouts and then resumes to normal.
This only happens in these high-throughput scenarios.
Are there any driver parameters that can solve this problem?

Hi Felipe,

Welcome to MongoDB Community!

Are there any driver parameters that can solve this problem?

Yes. Have you tried the “connectTimeoutMS” and “socketTimeoutMS” options in your connection string?

Kind regards,

1 Like

Hi, Martin!

We have several setttings in the string already:


I`ve thought about server selection timeout, because what it seems to me is that during the EC2 stop/start, the application doesn’t understand that the node is down. Or maybe some fine tuning in one of these parameters?

kind regards,

Hi Felipe,

I see. I haven’t tested myself the serverSelectionTimeoutMS option but I think you are correct to believe this option might do the trick.

It’s an easy test to perform on a development environment in AWS. I would also add the localThresholdMS option and keep the ones you already have.

Let us know how this works for you.

Kind regards,

1 Like