Skip to content

Instantly share code, notes, and snippets.

@SaleemJavid
Created July 21, 2011 21:56
Show Gist options
  • Select an option

  • Save SaleemJavid/1098326 to your computer and use it in GitHub Desktop.

Select an option

Save SaleemJavid/1098326 to your computer and use it in GitHub Desktop.
The config settings for mongo server on C# driver
private static Driver.MongoConnectionStringBuilder GetConnectionStringBuilder(string serverString)
{
var builder = new Driver.MongoConnectionStringBuilder(serverString);
builder.MinConnectionPoolSize = DriverInterfaceConfig.MinPoolSize;
builder.MaxConnectionPoolSize = DriverInterfaceConfig.MaxPoolSize;
builder.WaitQueueMultiple = DriverInterfaceConfig.WaitQueueMultiple;
// if maxpoolsize = 20
// and waitqueuemultiple = 3
// then number of requests that will be put in queue waiting for free connection is 20*3
//
builder.ConnectTimeout = DriverInterfaceConfig.ConnectionTimeOut;
return builder;
}
private static Driver.MongoServer GetPooledConnection(string serverString)
{
// serverString "Server=localhost:27017"
var builder = GetConnectionStringBuilder(serverString);
var settings = builder.ToServerSettings();
Driver.MongoServer server = MongoDB.Driver.MongoServer.Create(settings);
return server;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment