Open hero5512 opened 4 years ago
使用jodis对Codis压测与使用redis-benchmark压测性能差距很大,不知道原因是什么。 其中使用jodis的程序代码为: import io.codis.jodis.JedisResourcePool; import io.codis.jodis.RoundRobinJedisPool; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPoolConfig;
public class TestServer extends Thread {
private static JedisResourcePool jedisResourcePool;
private static int loop = 1000000000;
private static final int threadNum = 300;
private static final String key = "test";
static { JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); jedisPoolConfig.setMaxTotal(300); jedisPoolConfig.setMaxIdle(300); jedisPoolConfig.setJmxEnabled(true);
jedisResourcePool = RoundRobinJedisPool.create() .curatorClient("172.168.3.116:2181", 3000).poolConfig(jedisPoolConfig) .zkProxyDir("/jodis/codis-demo").build();
}
public void run() { Jedis jedis = jedisResourcePool.getResource(); for (int i = 0; i < loop; i++) { jedis.set(key + i, key + i); System.out.println(Thread.currentThread().getName() + "-------------------" + jedis.get(key + i)); } }
public static void main(String[] args) { for (int i = 0; i < threadNum; i++) { new TestServer().start(); }
} } 使用benchmark的命令行为: sudo /usr/bin/redis-benchmark -h 172.168.3.61 -p 19000 -c 300 -n 100000 -l
性能测试结果分别为20k和100k,请问是什么原因呢?
使用jodis对Codis压测与使用redis-benchmark压测性能差距很大,不知道原因是什么。 其中使用jodis的程序代码为: import io.codis.jodis.JedisResourcePool; import io.codis.jodis.RoundRobinJedisPool; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPoolConfig;
public class TestServer extends Thread {
private static JedisResourcePool jedisResourcePool;
private static int loop = 1000000000;
private static final int threadNum = 300;
private static final String key = "test";
static { JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); jedisPoolConfig.setMaxTotal(300); jedisPoolConfig.setMaxIdle(300); jedisPoolConfig.setJmxEnabled(true);
}
public void run() { Jedis jedis = jedisResourcePool.getResource(); for (int i = 0; i < loop; i++) { jedis.set(key + i, key + i); System.out.println(Thread.currentThread().getName() + "-------------------" + jedis.get(key + i)); } }
public static void main(String[] args) { for (int i = 0; i < threadNum; i++) { new TestServer().start(); }
} } 使用benchmark的命令行为: sudo /usr/bin/redis-benchmark -h 172.168.3.61 -p 19000 -c 300 -n 100000 -l
性能测试结果分别为20k和100k,请问是什么原因呢?