Mongo Connection Pooling(Changing the size of connection pool)

前端 未结 3 401
渐次进展
渐次进展 2021-01-22 22:56

How to change the mongo connection pool size?

I have seen it is 100 by default. Is there a way to change this value?

I dont want to do it via spring, is there a

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-22 23:41

    You can build your own MongoClient instance using the MongoClientOptions.Builder.

    MongoClientOptions.Builder builder = new MongoClientOptions.Builder();
    MongoClientOptions options = builder.connectionsPerHost(10).build();
    MongoClient client = new MongoClient(listOfServers, options);
    

提交回复
热议问题