Mongo C# 驱动程序对象分配
想象一下,您有一个操作系统进程,其中包括多个独立的并发代理,并且每个代理都需要独立访问 MongoDb 服务器并对其进行读写。其中许多读取和写入可能针对 MongoDb 服务器上的同一数据库和集合。
我应该如何允许每个代理创建自己的 MongoServer、MongoDatabase、MongoCollection 实例?在一个操作系统进程中可以拥有这些对象的多个实例吗? (可能有 10000 个代理)这会造成任何瓶颈吗?
每次代理调用 Mongo 服务器时,我是否应该获取这些对象(MongoServer、MongoDatabase、MongoCollection)的新实例,或者每个代理都可以保留 、
当我在一个进程中有这么多代理访问 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.
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?
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?
Should I worry about connection pool when I have so many agents in one process aceesing the Mongo objects ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此处的工作单元讨论 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.