MongoDB PHP Driver connection survey
The purpose of this survey is to collect some information about how folks are using the PHP driver to connect to MongoDB.

These questions refer to the "mongodb" extension and "mongodb/mongodb" Composer package. If you're using the legacy "mongo" extension, please ignore this survey and consider upgrading :)

All questions are optional.
Sign in to Google to save your progress. Learn more
What is your name, company, and/or email address?
What is your connection string?
This is the first argument to the MongoDB\Client and MongoDB\Driver\Manager constructors. Please redact sensitive information, such as passwords.
What is your URI options array?
This is the second argument to the MongoDB\Client and MongoDB\Driver\Manager constructors. Please redact sensitive information, such as passwords.
MongoDB Deployment
The following questions ask about how MongoDB is deployed. These questions will give us a sense of how the driver needs to monitor its connections and possible constraints on the server side.
What is your MongoDB topology?
Clear selection
How is MongoDB hosted?
If using MongoDB Atlas or another cloud provider, please also specify the deployment level (e.g. Atlas M10) so we have some sense of its resource limits.
Additional details about your MongoDB deployment
Please use this space to provide any other notes or details pertinent to your MongoDB deployment. For instance, if the driver must connect through a firewall or load balancer to access the MongoDB servers, you can discuss that here.
PHP Deployment
The following questions ask about how PHP is deployed. Since the PHP driver persists connections in memory (see: http://php.net/manual/en/mongodb.connection-handling.php), these questions should indicate how many persistent connections the application should maintain at peak operation.
What PHP SAPI do you primarily use?
Clear selection
Approximately how many PHP workers do you have?
If using Apache and mod_php, this should be the total number of application servers running Apache multiplied by the number of request workers in each Apache instance. If using FPM, this should be the total number of application servers running FPM multiplied by the number of PHP workers in each FPM instance. If the range of application servers and/or pool of workers is dynamic, please note that in your response and provide the upper bound.
URI Options
The following questions ask about specific URI options, which are specified in either the URI string or URI options array (i.e. first and second arguments to the MongoDB\Client and MongoDB\Driver\Manager constructors.

Note: Values in the URI options array take precedence over values in the URI string, so please keep that in mind when answering. For example, if the URI string includes "ssl=true" and the options array specifies "ssl=false", the reported value should be "false".
What do you specify for ssl?
Initiates the connection with TLS/SSL if true.
Clear selection
What do you specify for authMechanism?
The authentication mechanism that MongoDB will use to authenticate the connection. See: https://docs.mongodb.com/manual/reference/connection-string/#urioption.authMechanism 
Clear selection
What do you specify for connectTimeoutMS?
The time in milliseconds to attempt a connection before timing out.
Clear selection
What do you specify for socketTimeoutMS?
The time in milliseconds to attempt a send or receive on a socket before timing out.
Clear selection
What do you specify for serverSelectionTimeoutMS?
Specifies how long in milliseconds to block for server selection before throwing an exception.
Clear selection
What do you specify for serverSelectionTryOnce?
When true, instructs the driver to scan the MongoDB deployment exactly once after server selection fails and then either select a server or raise an error. When false, the driver blocks and searches for a server up to the "serverSelectionTimeoutMS" value.
Clear selection
What do you specify for socketCheckIntervalMS?
If a socket has not been used recently, the driver must check it via an isMaster command before using it for any operation.
Clear selection
What do you specify for heartbeatFrequencyMS?
Specifies the interval in milliseconds between the driver's checks of the MongoDB topology, counted from the end of the previous check until the beginning of the next one. Per the Server Discovery and Monitoring specification, this value cannot be less than 500 milliseconds.
Clear selection
What do you specify for retryWrites?
If true, the driver will automatically retry certain write operations that fail due to transient network errors or replica set elections (only for MongoDB 3.6+ replica sets and sharded clusters). If a write operation is retried, the driver will re-enter server selection and attempt to select a new primary with which to retry the write operation once. If the retry attempt also fails, or a new primary cannot be selected, an exception is raised. This is discussed in greater detail in the Retryable Writes specification (https://github.com/mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.rst).
Clear selection
Were any of the aforementioned URI options unfamiliar to you?
Please check all that apply.
Dealing with Connection Errors
As a single-threaded driver, the PHP driver must monitor its MongoDB connections between database commands issued by your application (e.g. commands, queries, and writes). This is discussed in much greater detail in the Server Discovery and Monitoring (https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst) and Server Selection (https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst) specifications.

Threaded MongoDB drivers may spend up to 30-seconds (by default) in a loop while attempting to select a server, which allows for them to insulate applications for connection errors related to replica set failovers. The single-threaded PHP driver instead defaults to one attempt to select a server and "fails fast" if a server cannot be selected for an operation. In practice, this means that the PHP driver will generally throw an exception if a primary is unavailable due to a replica set failover.

The PHP driver allows this behavior to be customized via the serverSelectionTryOnce and serverSelectionTimeoutMS URI options. If serverSelectionTryOnce is true (default), serverSelectionTimeoutMS (default: 30 seconds) determines the maximum amount of time to spend during the first and only selection attempt. If serverSelectionTryOnce is false, serverSelectionTimeoutMS determines the maximum amount of time to spend during the server selection loop.
What behavior is more important to your application?
Clear selection
How does your web application deal with blocked requests?
Regardless of whether FPM or Apache mod_php is used, each worker can handle a single web request at a time. If server selection is allowed to block web requests and there are not enough idle workers available, the application servers will either need to spawn additional workers (which may also attempt to connect to MongoDB) or reject incoming requests if a worker spawn limit is reached (e.g. pm.max_children for FPM).
Clear selection
Persistent Connections
The PHP driver persists server connections based on the MongoDB\Driver\Manager constructor arguments (http://php.net/manual/en/mongodb.connection-handling.php). This is comparable to using persistent sockets with other database drivers in PHP (http://php.net/manual/en/features.persistent-connections.php) in that the connections will remain open after the PHP request completes and ultimately close when the PHP worker itself terminates.

If you have previously requested an API in the PHP driver to manually close connections or otherwise disable connection persistence, please use this section to elaborate on your use case. If not, feel free to ignore this section.
What is your use case for disabling connection persistence?
Note that disabling connection persistence will incur overhead of discovering the MongoDB topology on each request. There may be additional overhead if TLS/SSL connections and authentication are used. Please discuss how your application would deal with that overhead.
Submit
Clear form
Never submit passwords through Google Forms.
This form was created inside of 10gen. Report Abuse