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.