2017-09-04 54 views
1

Jedis接続プールでRedisを使用する際に問題が発生しています。Jedis接続が解放されていません

私が見ている動作は、接続が確立された後、接続プールに戻されていないことです。

私はredis-cli client listコマンドを使用しているので、まだ接続が掛かっていることがわかります。

誰かが私のjedis接続プールを確認して、問題が原因である可能性があるかどうかを教えてください。

 <spring:bean id="ElasticachePoolConfig" name="ElasticachePoolConfig" class="redis.clients.jedis.JedisPoolConfig" > 

     <!-- Minimum number of idle connections to Redis - these can be seen as always open and ready to serve --> 
     <spring:property name="minIdle" value="${redis.minIdle}" /> 

     <!-- Number of connections to Redis that just sit there and do nothing --> 
     <spring:property name="maxIdle" value="${redis.maxIdle}" /> 

     <!-- Maximum number of active connections that can be allocated from this pool at the same time --> 
     <spring:property name="maxTotal" value="${redis.maxTotal}" /> 

     <!-- The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor.--> 
     <spring:property name="minEvictableIdleTimeMillis" value="${redis.minEvictableIdleTimeMillis}" /> 

     <!-- The minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by the idle connection evictor --> 
     <spring:property name="softMinEvictableIdleTimeMillis" value="${redis.softMinEvictableIdleTimeMillis}" /> 

     <!-- The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception --> 
     <spring:property name="maxWaitMillis" value="${redis.maxWaitMillis}" /> 

     <!-- Maximum number of connections to test in each idle check --> 
     <spring:property name="numTestsPerEvictionRun" value="${redis.numTestsPerEvictionRun}" /> 

     <!-- Tests whether connection is dead when connection retrieval method is called --> 
     <spring:property name="testOnBorrow" value="${redis.testOnBorrow}" /> 

     <!-- Tests whether connection is dead when returning a connection to the pool --> 
     <spring:property name="testOnReturn" value="${redis.testOnReturn}" /> 

     <!-- Tests whether connections are dead during idle periods --> 
     <spring:property name="testWhileIdle" value="${redis.testWhileIdle}" /> 

     <!-- Idle connection checking period --> 
     <spring:property name="timeBetweenEvictionRunsMillis" value="${redis.timeBetweenEvictionRunsMillis}" /> 

     <spring:property name="blockWhenExhausted" value="${redis.blockWhenExhausted}" /> 

    </spring:bean> 

次のようにプロパティが設定されている場合...

redis.port=6379 
redis.timeout=2000 
redis.ttl=600 
redis.host=localhost 
redis.repeater.maxRetries=3 
redis.repeater.millisBetweenRetries=2000 
redis.minIdle=5 
redis.maxIdle=10 
redis.maxTotal=8 
redis.minEvictableIdleTimeMillis=30000 
redis.softMinEvictableIdleTimeMillis=-1 
redis.maxWaitMillis=5000 
redis.numTestsPerEvictionRun=10 
redis.testOnBorrow=true 
redis.testOnReturn=true 
redis.testWhileIdle=false 
redis.timeBetweenEvictionRunsMillis=50000 
redis.blockWhenExhausted=true 
+0

"接続が確立された後、接続プールに戻ってきていないことがわかります。これは、redis-cliクライアントリストコマンドを使用すると接続が引き続き表示されるためです。非連続。接続は周囲にとどまるはずです。 * open *接続を接続プールに戻します。閉じたものではありません。 – hobbs

+0

こんにちは@hobbsは応答に感謝します。あなたが正しい。しかし、退去時に接続が私の最小アイドル接続に戻らないようにしてください。 – Richie

+0

それは 'maxIdle'以下に落ちるはずです。 – hobbs

答えて

0

あなたmaxIdle設定では、あなたのmaxTotalの設定よりも大きくなっているので、事実上何の接続がアイドル状態にリリースされません。プールはmaxIdle接続を維持します。

JedisPoolはApache Commons Poolingを内部的に使用します。 maxIdlemaxTotalの違いについては、this answerを参照してください。

関連する問題