I’ve opened an issue on the mongo remix example here.
After not hearing back on the issue, I contacted support who pointed me here.
Is anyone able to confirm if I’m using the driver correctly? It’s a serious concern for me that the connections increase until a new deployment.
I can’t find a definitive answer on whether I should be storing the client in memory, like I am, storing the “db” in memory, or even storing each “collection” in memory.
In contrast to the remix example, the mongo university example stores the “collection” in memory.
May I ask what specific issues you are facing with the increased number of connections? Also, could you further clarify “connections increase until a new deployment”?
However, here the drivers maintain a connection pool, i.e., monitoring threads, rather than a single connection for all the operations, so there can be multiple connections to the cluster from a client.
It depends on your application’s use case and your desired approach for connection reuse. If your application frequently interacts with a particular database, it can be beneficial to store it in a variable and access it throughout the application. This concept extends to the client connection as well. By storing and reusing these connections, you can optimize your application’s performance and resource usage. Eventually, the decision should align with your application’s use case and requirements.