Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting JedisPoolConfig testOnBorrow to false

So, currently in my JedisPoolConfig bean, I have the parameter testOnBorrow set to true. It appears this retrieving resources slower.

There was a scenario where Jedis took 30minutes to retrieve resources from Redis (calling methods (redis.clients.jedis.BinaryJedis:exists:144 and java.lang.Thread:sleep) several times before getting a resource or breaking away).

What I thought I could do was set parameter testOnBorrow to false to prevent PING calls to Redis before reading resources.

So, my questions (and I really hope I get answers) are:

  1. "What will setting this parameter do to my app"?
  2. "Is this solution really effective?"
  3. "Is there a better solution to this problem of slow-reading?"
like image 429
Sulaiman Adeeyo Avatar asked Dec 15 '22 06:12

Sulaiman Adeeyo


1 Answers

Jedis testOnX settings simply send a Redis PING command on certain scenarios. testOnBorrow sends them when receiving a connection from the pool.

Disabling it will make your work with Redis faster, as you skip the validation which means one less TTL. Note that your app should know how to handle a bad connection object, but this is true also with the test enabled as the connection can close/drop also after the test and before your usage.

That said, 30 minutes is eternity, and most definitely not happening because you send a PING request. Make sure you return the connections to the pool once done, and make sure your pool size is large enough for your application usage.

like image 140
Ofir Luzon Avatar answered Dec 17 '22 02:12

Ofir Luzon