我正在使用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