Hi,
I’m working on a multi-threading C server where I use mongo as database.
For that, I’m using the mongo connection pooling. When my server process multiple connections, I have noticed very high CPU usage by my application due to multiple mongo connections.
My questions are :
Is it possible to avoid opening multiple connections each time we pop a mongo client ?
Is it possible to execute mongo operations after pushing a mongo client to the pool ? (as it shown below) :
mongoc_client_t *client;
client = mongoc_client_pool_pop (pool);
collection = mongoc_client_get_collection(client, "database", "collection");
mongoc_client_pool_push (pool, client);
// Use collection to insert, get or update documents after pushing the mongo client
Thanks for the reply, I solved the performance issue by removing minpoolsize config (it was set to 1). however after reading all the doc I couldn’t find an answer for my 2nd question :
Is it possible to execute mongo operations after pushing a mongo client to the pool ? (as it shown below) :
mongoc_client_t *client;
client = mongoc_client_pool_pop (pool);
collection = mongoc_client_get_collection(client, "database", "collection");
mongoc_client_pool_push (pool, client);
// Use collection to insert, get or update documents after pushing the mongo client
From this example and this api description it appears to me that after a client pool push you can no longer use the connection. You must obtain the mongoc_client_t via a client pool pop and push it back when done.