简体   繁体   English

使用C#驱动程序的MongoDB连接池

[英]MongoDB connection pooling with the c# driver

We've been reading the MongoDB driver documentation for v2.4 (yes, we're on a REALLY OLD version of MongoDB right now): 我们正在阅读v2.4的MongoDB驱动程序文档(是的,我们现在使用的是MongoDB的非常老的版本):

https://docs.mongodb.com/v2.4/reference/connection-string/ https://docs.mongodb.com/v2.4/reference/connection-string/

While we understand that maxPoolSize allows you to configure the maximum number of connections in the pool, we're wondering HOW that pool is managed. 虽然我们知道maxPoolSize允许您配置池中的最大连接数,但我们想知道如何管理该池。

Specifically, are the connections pre-allocated for each client that connects? 具体来说,是否为每个连接的客户端预先分配了连接? With a default of 100 for maxPoolSize, does that mean each client causes a pool of 100 connections to be created on the server? maxPoolSize的默认值为100,是否意味着每个客户端都会在服务器上创建100个连接的池? Or are the connections in the pool created as needed, up to that maximum? 还是根据需要在池中创建连接,直至达到最大值?

Pointers to any tutorials or best practices documentation on this topic would be appreciated, thanks! 谢谢您对本主题的任何教程或最佳实践文档的指点!

Connection pool size is not about user, it is about request. 连接池的大小与用户无关,而与请求有关。 If you do 100 requests in parallel to db they use all your connection pool. 如果您与db并行执行100个请求,它们将使用您的所有连接池。 Roughly said one user can use all connection pool if run 100 parallel threads which interract with db. 粗略地说,如果运行100个与db干扰的并行线程,则一个用户可以使用所有连接池。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM