iCode
iCode

Reputation: 4338

Mongo C# Driver Object Allocation

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 ?

Upvotes: 2

Views: 460

Answers (1)

Meligy
Meligy

Reputation: 36594

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.

Upvotes: 2

Related Questions