Does Jedis run Info/Ping on its own ?

518 views
Skip to first unread message

Guy Lubovitch

unread,
Dec 15, 2014, 8:53:51 AM12/15/14
to jedis...@googlegroups.com
I am running a benchmark on Jedis 2.6.1 and i also tried 2.5.2. i see in my stats there are none set/get command, i only run set/get 

Does jedis perform these commands ?

i notice this only on many threads and high load. 

Guy 

임정택

unread,
Dec 16, 2014, 9:38:58 PM12/16/14
to jedis...@googlegroups.com
Sorry but could you elaborate?
Jedis doesn't make anything without Redis.

2014년 12월 15일 월요일 오후 10시 53분 51초 UTC+9, Guy Lubovitch 님의 말:

Guy Lubovitch

unread,
Dec 17, 2014, 2:59:06 AM12/17/14
to jedis...@googlegroups.com
Sure, i am running a benchmark using Jedis and i notice in the commandstats that other commands are being executed. i am only doing set/get commands. 

so checking if that is possible?

--
You received this message because you are subscribed to a topic in the Google Groups "Jedis" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jedis_redis/prOU6Y_OX7o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jedis_redis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jonathan Leibiusky

unread,
Dec 17, 2014, 7:38:25 AM12/17/14
to jedis...@googlegroups.com
Can you show us how you are using jedis?
There are conrigurations of JedisPool that performs a PING command every time you borrow a Jedis instance from it.

You received this message because you are subscribed to the Google Groups "Jedis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jedis_redis...@googlegroups.com.

Guy Lubovitch

unread,
Dec 17, 2014, 7:43:32 AM12/17/14
to jedis...@googlegroups.com
I use very simple configuration  ( i know i dont handle fail over for now) :

JedisPoolConfig poolConfig=new JedisPoolConfig();
poolConfig.setMaxTotal(500);
pool = new JedisPool(poolConfig, host , port);
@Override
public void set(String key, String value) {

Jedis jedis = pool.getResource();

jedis.set(key,value);

pool.returnResource(jedis);
}

Jonathan Leibiusky

unread,
Dec 17, 2014, 8:09:20 AM12/17/14
to jedis...@googlegroups.com
Ok. That is the reason then.
JedisPool by default does a "check on borrow". This means: send a PING command everytime that you borrow a Jedis instance from the pool.
This is a way to make sure that connections borrowed from the pool are healthy.
Now, you can disable that of course and change the configuration of the pool to meet your needs :)

Guy Lubovitch

unread,
Dec 17, 2014, 8:32:21 AM12/17/14
to jedis...@googlegroups.com
How do i disable this ? i am not sure if its good to have this enable by default. also the number do not match this exactly as i am performing getResource for every set and i dont see ping as much as i see set. 

임정택

unread,
Dec 17, 2014, 9:57:55 AM12/17/14
to jedis...@googlegroups.com
JedisPoolConfig's setting is 'test while idle'.
So PING count may differ, maybe less than 'test with borrow'.
You can configure pool config manually, details are on Apache Commons Pool 2.

package redis.clients.jedis;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

public class JedisPoolConfig extends GenericObjectPoolConfig {
public JedisPoolConfig() {
// defaults to make your life with connection pool easier :)
setTestWhileIdle(true);
setMinEvictableIdleTimeMillis(60000);
setTimeBetweenEvictionRunsMillis(30000);
setNumTestsPerEvictionRun(-1);

Guy Lubovitch

unread,
Dec 17, 2014, 10:18:06 AM12/17/14
to jedis...@googlegroups.com
Thanks for this, i guess the example you gave do not disable ping. 

임정택

unread,
Dec 17, 2014, 10:31:25 AM12/17/14
to jedis...@googlegroups.com
Source code that I gave is actual implementation of JedisPoolConfig.
You can find more from GenericObjectPoolConfig, see setTestXXX to disable validation of connection.

Guy Lubovitch

unread,
Dec 18, 2014, 1:51:45 AM12/18/14
to jedis...@googlegroups.com
Thanks, my new pool config 

JedisPoolConfig poolConfig=new JedisPoolConfig();

// defaults to make your life with connection pool easier :)
poolConfig.setTestWhileIdle(false);
poolConfig.setTestOnBorrow(false);
poolConfig.setTestOnReturn(false);
poolConfig.setMinEvictableIdleTimeMillis(60000);
poolConfig.setTimeBetweenEvictionRunsMillis(30000);
poolConfig.setNumTestsPerEvictionRun(-1);
poolConfig.setMaxTotal(500);

pool = new JedisPool(poolConfig, host , port);
Reply all
Reply to author
Forward
0 new messages