之前百度,google了很多,发现并没有介绍mongodb生产环境如何配置的文章, 当时想参考下都不行, 所以写篇文章,大家可以一块讨论下.
1. MongoClientOptions中的连接池配置:配置如下:
connectionPoolSettings = ConnectionPoolSettings.builder() .minSize(getMinConnectionsPerHost()) .maxSize(getConnectionsPerHost()) .maxWaitQueueSize(getThreadsAllowedToBlockForConnectionMultiplier() * getConnectionsPerHost()) .maxWaitTime(getMaxWaitTime(), MILLISECONDS) .maxConnectionIdleTime(getMaxConnectionIdleTime(), MILLISECONDS) .maxConnectionLifeTime(getMaxConnectionLifeTime(), MILLISECONDS) .build();