search

Home  >  Q&A  >  body text

mongodb - mongo php-fpm 连接池问题

用nginx+gridfs的方式,mongos的日志中保持稳定的连接数。
php-fpm模式连接mongo,如果不做close操作连接,压力测试,直接爆掉mongos的连接。
close的话,日志里直接end connection,手册里说好的连接池捏~~~
http://cn2.php.net/manual/en/mongo.co...

mongodb 2.0
pecl mongo 1.2.12

黄舟黄舟2767 days ago979

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-21 10:58:23

    The document mentions that connections_per_pool defaults to unlimited, which means there is no limit to the number of connections that can be created in each connection pool.

    You can use MongoPool::setSize to limit: http://php.net/manual/en/mongopool.se...

    In addition, Mongo 2.2+ with Mongo PECL extension 1.3+ (beta) can support single connection reuse, it is recommended to pay attention.

    UPDATE:

    On top of this new framework, new functionality is also implemented to provide read preference support that comes with MongoDB 2.2. The new framework no longer has the concept of a connection pool, but instead make sure there is only one connect per node/db /username.

    This means that a fixed number of connections can be maintained like an nginx proxy, like a "pipeline", but a connection pool is not equal to a pipe.

    The ext-mongo solution of MongoDB 2.0 and 1.2.x does not support pipes. Concurrent scripts will not reuse connections. When a script releases the connection used, another script can use it from the connection pool. .

    reply
    0
  • Cancelreply