mongodb连接配置实践

之前百度,google了很多,发现并没有介绍mongodb生产环境如何配置的文章, 当时想参考下都不行, 所以写篇文章,大家可以一块讨论下.

1. MongoClientOptions中的连接池配置:

配置如下:

connectionPoolSettings = ConnectionPoolSettings.builder() .minSize(getMinConnectionsPerHost()) .maxSize(getConnectionsPerHost()) .maxWaitQueueSize(getThreadsAllowedToBlockForConnectionMultiplier() * getConnectionsPerHost()) .maxWaitTime(getMaxWaitTime(), MILLISECONDS) .maxConnectionIdleTime(getMaxConnectionIdleTime(), MILLISECONDS) .maxConnectionLifeTime(getMaxConnectionLifeTime(), MILLISECONDS) .build();

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpxddg.html