doctrine / mongodb

PHP MongoDB Abstraction Layer
https://www.doctrine-project.org/projects/mongodb.html
MIT License
442 stars 190 forks source link

Support for MongoDB Driver #299

Closed lopezio closed 7 years ago

lopezio commented 7 years ago

Hi Folks,

Is anyone here already working on switching to the new PHP MongoDB Driver ( http://php.net/manual/en/set.mongodb.php )? Particularly the connection pooling of it is very interesting. If no one is working on it, I can give it a take and then hand it over.

Best Wishes!

Lorenzo

alcaeus commented 7 years ago

This library will not be adapted to use the new driver. If you're looking for a replacement of this library, you can check out the MongoDB PHP library: https://github.com/mongodb/mongo-php-library.

We are in the process of adapting Doctrine MongoDB ODM to use the new library (and thus the new driver). You can track progress for this rewrite in https://github.com/doctrine/mongodb-odm/pull/1553.

jmikola commented 7 years ago

Particularly the connection pooling of it is very interesting.

For the record, ext-mongodb does not provide any connection pooling (nor did ext-mongo before it):

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.

That quote is taken from MongoDB\Driver\Manager::__construct(). The connection persistence model implemented by the extension is documented in the Connection Handling article. Please note the difference between connection pooling and persistence.

lopezio commented 7 years ago

For the record, ext-mongodb does not provide any connection pooling (nor did ext-mongo before it):

Gosh, you're right. I must have been blinded by hope. The lack of connection pooling is one of the most annoying performance bottlenecks when using MongoDB with PHP. Using mongos even with mono-shard setups helps a bit (but also reduces redundancy, because the only way to mitigate it is to point to only one mongos), but is very far from being a solution. Let's hope pooling will find it's way to the new PHP extension.

Thanks a lot for pointing it out and redirecting me to the issue.

jmikola commented 7 years ago

Let's hope pooling will find it's way to the new PHP extension.

The very idea of connection pooling conflicts with PHP's architecture for request handling. Note that this is a general problem for all database drivers (see: https://stackoverflow.com/q/39753/162228).