Reputation: 1617
I want to have persistent connection active by default on my Mongodb HTTPS server.
What is the right set of configuration to achieve it? Example: max connection lifetime, max number of persistent connections...
Is there a chance to optimise these settings or at least see their values?
phpinfo() does not tell me anything.
Upvotes: 1
Views: 3313
Reputation: 278
With connection pooling being deprecated since mongo 1.2.3 you can no longer get or set the size of the pool (the connections stored in there to be fetched when there is a demand). Connections are managed by PHP and that means that it stores 'hashes' containing information such as host, port, database name, process id etc that identify a unique connection.
You can set the maximum simultaneous connections though (persistent is the new default as you mentioned) through the actual mongod process if you have access to, not through PHP. Server-side, you can run a mongod instance with the parameter --maxConns = 5000
to control the maximum connections for it.
Persistent connection lifetime is not adjustable or viewable as of yet. You would not really need it anyway as new connections overwrite old ones. Unused persistent connections do no harm and new ones get registered, pushing old ones out. The lifetime therefore depends on the amount of new connections at each time.
Upvotes: 1
Reputation: 43884
It does not seem to be possible to configure the settings of the connections in that manner only to be able to set timeouts for certain connect actions: http://www.php.net/manual/en/mongoclient.construct.php
As for max number of persistent connections ( http://www.php.net/manual/en/mongo.connecting.pools.php ) the PHP MongoDB driver actually holds the number of connections it creates very stringently, as noted:
The latest versions of the driver have no concept of pooling anymore and will maintain only one connection per process, for each connection type (ReplicaSet/standalone/mongos), for each credentials combination.
So obviously the amount of connections depends on the amount of type of connections you are using and how many PHP processes have been spun up, not some value in the configuration.
Upvotes: 3