Problem occurs environment: nginxphp 5.3.10 as php-fpm extension to Nginxmongodb-php-driver 1.2.12MongoDB 2.2 This issue is the official of MongoDB PHP driver 1.2.x Properties, see PHP-202 and PHP-347 for descriptions. In short, php-fpm mode, each PHP Worker process has its own separate MongoDB connection pool, resulting in the number of connections is extremely easy to exceed the number of memory multiplied. One, PHP service background: A WEB application is serviced by a PHP program run by nginx+factcgi. The maximum number of PHP-FPM is set by the Max_children parameter of the php-fpm.conf (or pm=dynamic by the spare_servers+start_servers parameter synthesis). This value was set to 512. Two, MongoDB service background: The maximum number of connections for a MongoDB instance can be set through the Maxconns setting in the Startup parameter: Maxconns: The default value depends on the system limits (such as ulimit and file descriptor). If this parameter is not set, MongoDB does not limit the number of connections. But, you can't set more than 20,000. Generally do not deliberately set the Maxconns parameter. Third, the dreaded connection pool feature of MongoDB PHP Driver (BUG?) MongoDB officially provided by Mongodb-php-driver in 1.3.0 under Version (1.2.0~1.2.1X), with a horrible connection pooling implementation, when any query is executed, a connection is requested from the connection pool and then returned to the connection pool. The completion here means that the variable holding the connection leaves its scope. www.2cto.com php-fpm mode, a PHP WEB application can establish the number of concurrent connections to MongoDB instance as follows: Number of processes: Max-children = 512, then 512 processes; One MongoDB instance corresponds to a Connection pool: The master is configured with 165 and 1662 replica set instances; Number of connections in the connection pool: mongodb-php-driver There is no limit to this and can be increased indefinitely until the handle is exhausted. —————— Zheng: This method is calculated from Mongo.connecting.pools —————— according to the official MongoDB documentation, although it is theoretically possible to increase the number of connections indefinitely, actual observations have found that the number of connections between a Web Server and a MongoDB instance is usually stable on a value that does not fluctuate much. So, suppose a PHP Web app initiates a connection to mongodb-165 of: 750, the number of memory that the MongoDB instance needs to maintain at least: 750x default 10MB = 7.5 GB
http://www.bkjia.com/PHPjc/477804.html www.bkjia.com true http://www.bkjia.com/PHPjc/477804.html techarticle problem occurs environment: Nginx PHP 5.3.10 as php-fpm extension to Nginx mongodb-php-driver 1.2.12 MongoDB 2.2 This problem is MongoDB PHP driver 1 The official characteristics of the. 2.x result, description please see ...