MongoDB连接池耗尽
异常日志:
Out of semaphores to get db connection 查看源代码发现是连接池资源用尽:
查代码看原因:
DBPortPool 写道
if ( ! _waitingSem.tryAcquire() ) throw new SemaphoresOut();
_waitingSem初始化代码
DBPortPool 写道
_waitingSem = new Semaphore( _options.connectionsPerHost * _options.threadsAllowedToBlockForConnectionMultiplier );
MongoOptions 写道
public MongoOptions(){
reset();
}
publicvoidreset(){
connectionsPerHost=Bytes.CONNECTIONS_PER_HOST;
threadsAllowedToBlockForConnectionMultiplier=5;
maxWaitTime=1000*60*2;
connectTimeout=0;
socketTimeout=0;
socketKeepAlive=false;
autoConnectRetry=false;
maxAutoConnectRetryTime=0;
slaveOk=false;
safe=false;
w=0;
wtimeout=0;
fsync=false;
j=false;
dbDecoderFactory=DefaultDBDecoder.FACTORY;
socketFactory=SocketFactory.getDefault();
}其中:
static final int CONNECTIONS_PER_HOST = Integer.parseInt( System.getProperty( "MONGO.POOLSIZE" , "10" ) );
改变连接池大小:
1、可以通过系统属性改变连接池大小。
2、代码层面修改,new Mongo的时,先一个你需要的MongoOptions
相关推荐
huacuilaifa 2020-10-29
温攀峰 2020-08-17
幸运小侯子 2020-08-14
dongCSDN 2020-06-28
一恍过去 2020-06-26
qingmuluoyang 2020-06-26
jameszgw 2020-06-25
Rain 2020-06-25
MissFuTT 2020-06-16
标题无所谓 2020-06-14
xclxcl 2020-06-13
onlypersevere 2020-06-13
dongCSDN 2020-06-09
llltaotao 2020-06-03
GavinZhera 2020-06-03
langyue 2020-05-31
牧场SZShepherd 2020-05-27
geek00 2020-05-27
zhaolisha 2020-05-16