Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php mongodb connect pool #688

Closed
fancyecommerce opened this issue Dec 5, 2017 · 1 comment
Closed

php mongodb connect pool #688

fancyecommerce opened this issue Dec 5, 2017 · 1 comment
Labels

Comments

@fancyecommerce
Copy link

fancyecommerce commented Dec 5, 2017

doc : https://github.com/mongodb/mongo-php-driver/issues

For details on supported options, see
 » Connection String Options in the MongoDB manual. 
» Connection pool options are not supported, as the PHP driver does not implement connection pools.

mongodb doc: https://docs.mongodb.com/manual/reference/connection-string/#connection-pool-options

ask:

  1. php mongodb default connection pool is 100, or 1 ?

  2. How do I implement a connection pool in php?

@jmikola
Copy link
Member

jmikola commented Dec 5, 2017

  1. php mongodb default connection pool is 100, or 1 ?
  2. How do I implement a connection pool in php?

The PHP driver uses libmongoc's single-threaded client mode, which does not implement connection pools. There is also no way to implement your own connection pooling using this driver.

Each single-threaded libmongoc client object maintains at most one socket connection per mongod or mongos server. The relationship between MongoDB\Driver\Manager objects and libmongoc client objects is discussed in Connection Handling in the driver documentation.

Connection pools should not be needed for any single-threaded application, unless you're using an async PHP framework (e.g. Amp, ReactPHP). In those cases, you'd probably need to implement your own driver as we provide no way to integrate libmongoc's IO with a PHP event loop. Multi-threaded PHP applications (e.g. pthreads, forking) are not supported by the driver.

@jmikola jmikola closed this as completed Jan 23, 2018
ravanscafi added a commit to leroy-merlin-br/mongolid that referenced this issue Oct 20, 2018
The PHP driver uses libmongoc's single-threaded client mode, which does not implement connection pools. There is also no way to implement your own connection pooling using this driver.

Each single-threaded libmongoc client object maintains at most one socket connection per mongod or mongos server. The relationship between MongoDB\Driver\Manager objects and libmongoc client objects is discussed in Connection Handling in the driver documentation.

Connection pools should not be needed for any single-threaded application, unless you're using an async PHP framework (e.g. Amp, ReactPHP). In those cases, you'd probably need to implement your own driver as we provide no way to integrate libmongoc's IO with a PHP event loop. Multi-threaded PHP applications (e.g. pthreads, forking) are not supported by the driver.
mongodb/mongo-php-driver#688 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants