2 回答

TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超21個(gè)贊
補(bǔ)充說明如下:
MongoDB Client驅(qū)動設(shè)置中網(wǎng)絡(luò)相關(guān)的等待設(shè)置比較多,依次介紹如下:
1、Client找Server所需要等待的時(shí)間,在RS或者Shard環(huán)境下,Client需要找到它所需的Server
對應(yīng)的參數(shù):ServerSelctionTimeOut
2、找到Server之后就需要建立Connection
1)每次都創(chuàng)建Connection,對應(yīng)的網(wǎng)絡(luò)等待的參數(shù)就是:connectTimeout2)Connection pooling的話,從Connection Pool取得Connection,對應(yīng)的網(wǎng)絡(luò)等待的參數(shù):maxWaitTime.
3、找到Connection之后,就有了Socket通信,在客戶端和MonogoDB的Socket通信過程中的網(wǎng)絡(luò)等待時(shí)間的參數(shù)就是:socketTimeout
供參考。
Love MongoDB!Have Fun!

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超6個(gè)贊
Stackoverflow上有一個(gè)有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).
- 2 回答
- 0 關(guān)注
- 1131 瀏覽
添加回答
舉報(bào)