Go mongo_driver create tons of connection when query from difference databases within a single mongo client

I’m writing a Go app using mongo-driver to connect to the mongo replica set.

I’ve noticed that mongo.Connect is not actually connected to the database.

Even if I’ve shutdown the mongod instance, mongo.Connect still able to pass through.

However, when I do the query it will connect to the mongod instance.

Now my problem is I have a lot (>100) concurrent queries to different databases within the same mongod instance.

The driver create a whole bunch of connections and mongod failed me Too many files opened because there are too many connections, Even I use a single mongo.Client .

Is it proper behavior that MongoDB required each connection per each database?
How can I deal with this?

checkout the maxPoolSize and minPoolSize this might help you in this scenario.