windows下redis和memcached的性能对比测试
2011-03-29 22:09
477 查看
在windows下测试了redis和memcached的性能,如下:
jedis get 20000次的执行时间:1265毫秒
jedis set 20000次的执行时间:1313毫秒
jedis 同时启动60个线程的执行时间:21609毫秒
xmemcached get执行20000次的时间:3219毫秒
xmemcached set 20000次的执行时间:3000毫秒
xmemcached 同时启动60个线程的执行时间:75562毫秒
可以看出redis的性能要好于memcached!
redis代码:
测试redis的代码时,发现同时启动的线程只能到达63,超过的线程都会失败。
排查很久,发现配置文件中有一句话:it's up to the number of file descriptors the Redis process is able to open.
估计在windows xp下只能到达64,那么还有一个呢?无法得知,查了好久也没有找到和linux下文件描述符想匹配的东西。
xmemcache代码:
jedis get 20000次的执行时间:1265毫秒
jedis set 20000次的执行时间:1313毫秒
jedis 同时启动60个线程的执行时间:21609毫秒
xmemcached get执行20000次的时间:3219毫秒
xmemcached set 20000次的执行时间:3000毫秒
xmemcached 同时启动60个线程的执行时间:75562毫秒
可以看出redis的性能要好于memcached!
redis代码:
public class Demo { public static void main(String[] args) throws Exception { Demo demo = new Demo(); demo.test(); } public void test() throws Exception { Jedis jedis = new Jedis("localhost"); jedis.set("key", "mykey"); long begin = System.currentTimeMillis(); for(int i=0; i<20000; i++) jedis.get("key"); long end = System.currentTimeMillis(); System.out.println("jedis get20000次的执行时间:" + (end - begin) + "毫秒"); begin = System.currentTimeMillis(); for(int i=0; i<20000; i++) jedis.set(String.valueOf(i), String.valueOf(i)); end = System.currentTimeMillis(); System.out.println("jedis set 20000次的执行时间:" + (end - begin) + "毫秒"); begin = System.currentTimeMillis(); Thread t[] = new Thread[60]; for(int j=0; j<t.length; j++) { t[j] = new TestThread(); t[j].start(); } for(int j=0; j<t.length; j++) { t[j].join(); } end = System.currentTimeMillis(); System.out.println("jedis 启动"+ t.length +"个线程的执行时间:" + (end - begin) + "毫秒"); } class TestThread extends Thread { @Override public void run() { Jedis jedis = new Jedis("localhost"); for(int i=0; i<20000; i++) jedis.get(String.valueOf(i)); jedis.disconnect(); } } }
测试redis的代码时,发现同时启动的线程只能到达63,超过的线程都会失败。
排查很久,发现配置文件中有一句话:it's up to the number of file descriptors the Redis process is able to open.
估计在windows xp下只能到达64,那么还有一个呢?无法得知,查了好久也没有找到和linux下文件描述符想匹配的东西。
xmemcache代码:
public class Demo { public static void main(String[] args) throws Exception { Demo demo = new Demo(); demo.test(); } public void test() throws Exception { MemcachedClient mc = new XMemcachedClient("localhost", 11211); mc.set("key", 2000, "mykey"); long begin = System.currentTimeMillis(); for(int i=0; i<20000; i++) mc.get("key", 1000); long end = System.currentTimeMillis(); System.out.println("memcached get执行20000次的时间:" + (end - begin) + "毫秒"); begin = System.currentTimeMillis(); for(int i=0; i<20000; i++) mc.set(String.valueOf(i), 2000 ,String.valueOf(i)); end = System.currentTimeMillis(); System.out.println("memcached set 20000次的执行时间:" + (end - begin) + "毫秒"); mc.shutdown(); begin = System.currentTimeMillis(); Thread t[] = new Thread[60]; for(int j=0; j<t.length; j++) { t[j] = new TestThread(); t[j].start(); } for(int j=0; j<t.length; j++) { t[j].join(); } end = System.currentTimeMillis(); System.out.println("memcached 启动"+ t.length +"个线程的执行时间:" + (end - begin) + "毫秒"); } class TestThread extends Thread { @Override public void run() { try { MemcachedClient mc = new XMemcachedClient("localhost", 11211); for(int i=0; i<20000; i++) mc.get(String.valueOf(i), 1000); mc.shutdown(); } catch (Exception e) { } } } }
相关文章推荐
- Memcached Redis Membase性能测试对比分析
- Kioskcached(1)之 Memcached & Redis & Kioskcached 性能测试对比
- Memcached Redis Membase性能测试对比分析
- Redis和Memcache性能测试对比
- Memcached与Redis的性能对比
- memcached与redis对性能对比
- memcached 和 redis 性能测试比对
- InnoDB memcached插件vs原生memcached对比性能测试
- Memcached与Redis的性能对比
- memcached&redis性能测试
- memcached&redis性能测试
- memcached与redis性能测试总结
- Ignite性能测试以及对redis的对比
- Redis和Memcached在功能、性能以及内存使用效率上的对比
- Redis和Memcache性能测试对比
- Redis和Memcache性能测试对比
- InnoDB memcached插件 vs 原生memcached对比性能测试
- InnoDB memcached插件vs原生memcached对比性能测试
- redis 集群性能测试以及与单机性能对比
- MemcacheDB, Tokyo Tyrant, Redis性能测试比较