Mongo C# 驱动程序对象分配

发布于 2025-01-05 19:48:14 字数 432 浏览 0 评论 0原文

想象一下,您有一个操作系统进程,其中包括多个独立的并发代理,并且每个代理都需要独立访问 MongoDb 服务器并对其进行读写。其中许多读取和写入可能针对 MongoDb 服务器上的同一数据库和集合。

  1. 我应该如何允许每个代理创建自己的 MongoServer、MongoDatabase、MongoCollection 实例?在一个操作系统进程中可以拥有这些对象的多个实例吗? (可能有 10000 个代理)这会造成任何瓶颈吗?

  2. 每次代理调用 Mongo 服务器时,我是否应该获取这些对象(MongoServer、MongoDatabase、MongoCollection)的新实例,或者每个代理都可以保留

  3. 当我在一个进程中有这么多代理访问 Mongo 对象时,我是否应该担心连接池?

Imagine you have an os process which includes several independent concurrent agents and each one of these agents will need to access the MongoDb server independently and read and write from/to it. Many of these read and writes could be to the same database and collection on the MongoDb server.

  1. How should I allow every one of these agents to create their own MongoServer, MongoDatabase, MongoCollection instances? Is it ok to have many instances of these objects in one os process? (there could be 10000 agents) Could that create any bottleneck?

  2. Everytime that an agent is making a call to the Mongo server, should I make it to get a get new instance of these objects (MongoServer, MongoDatabase, MongoCollection) or is it ok for each agent to hold on to its own instance of these object and use it for its life?

  3. Should I worry about connection pool when I have so many agents in one process aceesing the Mongo objects ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪淡了忧伤 2025-01-12 19:48:14

此处的工作单元讨论 mongodb 和 C# 中的工作单元 似乎对此有所了解,基本上是说这并不重要,与 ORM 中的上下文对象不同。

The Unit of Work discussion here Unit of work in mongodb and C# seems to draw some light on this, basically saying it doesn't really matter, unlike context objects in ORMs for example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文