Hello command when inserting documents?


In simple application that inserts lots of documents (calling mongoc_collection_replace_one) we notice when profiling the run that hello command seems to be run each time a new document (mongoc_server_description_handle_hello is called same times as mongoc_collection_replace_one).
Is this correct/expected, and is there a way to reduce these hello calls as they take significant time ?

Also, MongoDB wire protocol is documented but is there a set of guidelines for drivers implementors available to document what needs to be done when client application interacts with MongoDB server ?

Best regards

mongoc_server_description_handle_hello is also called when a mongoc_server_description_t is copied in mongoc_server_description_new_copy.

Most calls mongoc_server_description_handle_hello do not suggest a new hello response is being handled.

To observe when a hello new response is being handled, use mongoc_apm_set_server_heartbeat_succeeded_cb to observe when the driver completes a “hello” command to check the status of a server. Application Performance Monitoring (APM) — libmongoc 1.22.1 includes an example.

https://github.com/mongodb/specifications is intended for driver implementors. https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-monitoring.rst may be the most relevant.


Thanks for replying. From profiling done on a simple client that only writes documents it seems that hello command gets issued at each time a document is written. We were wondering if this is was by design or if it was possible to reduce the amount of these hello pings as they take some time ? We tried changing some config values without success.