MongoDB, MongoDB is act as connection pool for mongoDB and it is created per application and per DB basis.
Typically you only create one MongoClient instance for a given MongoDB deployment (e.g. standalone, replica set, or a sharded cluster) and use it across your application. However, if you do create multiple instances:
All resource usage limits (e.g. max connections, etc.) apply per MongoClient instance.
Ref: http://mongodb.github.io/mongo-java-driver/3.4/driver/tutorials/connect-to-mongodb/
MongoClientOptions options =
MongoClientOptions.builder()
.threadsAllowedToBlockForConnectionMultiplier(prop.getThreadsAllowedToBlock())
.connectionsPerHost(pro.getConnectionsPerHost())
.connectTimeout(prop.getConnectionTimeout())
.maxWaitTime(prop.getConnectionTimeout())
.socketTimeout(1000)
.heartbeatConnectTimeout(prop.getHeartbeatConnectTimeout())
.writeConcern(WriteConcern.ACKNOWLEDGED).build();
MongoClient mongoclient = new MongoClient(seeds,credential, options); credential, options);
This is working as connection pool. We can instantiate MongoTemplate from MongoClient.