php mongodb and,mongodb和php:连接池

我正在使用PHP中的本机驱动程序连接到mongo DB.

我不明白连接池的概念:这就像连接的“池”,当用户打开网站时,从该池中拉出连接并使用?

但是,如果您有多个页面,其中一些代码使用mongoDB,该怎么办?每次用户更改页面时,系统是否会从池中提取新连接?

通常:当有大量同时连接时,如何管理此“连接池”(或者是否自动管理)?

解决方法:

I don’t understand the concept of connection pooling: is this like a ‘pool’ of connections, and when a user opens the website, a connection is pulled from this pool and used?

是的,这正是它的本质.

But what if you have multiple pages with some code that uses a mongoDB? Will the system pull a new connection from the pool every time the user changes the page?

是.在需要时(用户加载页面)从池中获取连接,然后在脚本结束时返回池.它默认是持久的(通过mongo.allow_persistent php.ini设置设置)并由驱动程序自动处理.

In general: how can I manage this ‘connection pool’ (or is it managed automatically) when there are a lot of simultaneous connections?

连接池主要是自动管理的.您可以使用MongoPool类进行某种程度的控制.

标签:php,mongodb,connection-pooling

来源: https://codeday.me/bug/20190521/1146728.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值