为了账号安全,请及时绑定邮箱和手机立即绑定

mongodb的参数理解

mongodb的参数理解

富国沪深 2018-08-16 15:27:35
求问大神,对于mongodb以下几个参数我的理解对不对?maxWaitTime=120000 是指已经连接到mongodb,正在等待数据返回,这个等待的时间connectTimeout=10000 是指请求mongodb连接,还没有连接上,正在等待连接的时间socketTimeout=0 是指已经连接上了,正在传输数据,传输数据过程中会有耗时,这里就是等数据传递结束的等待时间
查看完整描述

2 回答

?
眼眸繁星

TA贡献1873条经验 获得超9个赞

MongoDB Client驱动设置中网络相关的等待设置比较多,依次介绍如下:

1、Client找Server所需要等待的时间,在RS或者Shard环境下,Client需要找到它所需的Server

对应的参数:ServerSelctionTimeOut

2、找到Server之后就需要建立Connection

1)每次都创建Connection,对应的网络等待的参数就是:connectTimeout
2)Connection pooling的话,从Connection Pool取得Connection,对应的网络等待的参数:maxWaitTime.

3、找到Connection之后,就有了Socket通信,在客户端和MonogoDB的Socket通信过程中的网络等待时间的参数就是:socketTimeout

供参考。

Love MongoDB!Have Fun!


查看完整回答
反对 回复 2018-08-26
?
慕慕森

TA贡献1856条经验 获得超17个赞

Stackoverflow上有一个有140次赞的回答:How to configure MongoDB Java driver MongoOptions for production use?

  • connectTimeout. As the name suggest number of milliseconds the driver will wait before a connection attempt is aborted. Set timeout to something long (15-30 seconds) unless there's a realistic, expected chance this will be in the way of otherwise succesful connection attempts. Normally if a connection attempt takes longer than a couple of seconds your network infrastructure isn't capable of high throughput.

  • maxWaitTime. Number of ms a thread will wait for a connection to become available on the connection pool, and raises an exception if this does not happen in time. Keep default.

  • socketTimeout. Standard socket timeout value. Set to 60 seconds (60000).


查看完整回答
反对 回复 2018-08-26
  • 2 回答
  • 0 关注
  • 693 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信