Closed ja-jimenez closed 4 years ago
The driver specification for monitoring describes this behavior: Monitoring
It is used to keep the current deployment up to date, for example in case that the primary server was changed. The monitor detects the new primary by calling isMaster command.
Hi @zookzook, thanks for you reply.
I have reviewed the spec but I think it doesn't give me whatever I need to known when a topology is not been used to make clients request like CRUD operations, and to stop it after some time, such as 60 seconds, to release database resources.
But after to read the spec I'm thinking this kind of functionality should be implemented in my app, not in the driver... ¿What do you think? ¿Could be interesting to add some kind of configuration param to the driver to stop a topology if there is no calls from app to driver in X seconds, or it must be implemented in the app?
Regards.
The monitoring process is always running and updates the topology descriptions, whatever kind of deployment (replica-set, standalone or mongos) is used, because the driver should follow the specification. I don't think, that releasing a database resources like network connection or socket resources has any advantages.
Do you have a special use case for this behaviour? What are the advantages?
Opening a new connection is more expensive than using an already established connection. And the isMaster
command keeps the connection alive.
I am thinking on stage where you have different customers, everyone using different database connections, such us if you build a platform for online stores. Each customer will have its clients, products, etc stored in a separate database.
In this case could be interesting to close connections if some of them are not doing requests. But, like I commented previously, maybe this functionality should be implemented in app side.
Hi!
When I create a new topology process using Mongo.start_link(opts), I see the following logs each 10 seconds, because that command is sent (I think) to MongoDB server:
So the connection with server is ever active. Is there any option to stop the topology process (and close the connection or pool connections with database) if there isn't any request from the client?
I mean, if the client doesn't call any function from Mongo or Session modules in X seconds, stop that topology process. An example:
Regards.