Ignite性能测试以及对Redis的对比(5)

下面是redis的测试代码

import redis.clients.jedis.Jedis; public class redis { private static final String ip = "192.168.49.200"; private static final String auth = "your pwd"; private static final Integer port = 6379; //测试的数据行数 private static final Integer test_rows = 50000; //线程数 private static final Integer thread_cnt = 200; public static void main(String[] args) { MultiThread(); } private static void MultiThread() { System.out.println("=================================================================="); System.out.println("开始测试多线程写入[线程数:"+thread_cnt+"]"); Long startTime = System.currentTimeMillis(); Thread[] threads = new Thread[thread_cnt]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new TestThread(true)); } for (int i = 0; i< threads.length; i++) { threads[i].start(); } for(Thread thread : threads){ try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } Long endTime=System.currentTimeMillis(); //获取结束时间 float interval = endTime-startTime == 0 ? 1 : endTime-startTime; float tpms = (float)test_rows/interval; System.out.println("程序运行时间: "+ interval+"ms"); System.out.println("每毫秒写入:"+tpms+"条。"); System.out.println("每秒写入:"+tpms*1000+"条。"); System.out.println("=================================================================="); System.out.println("开始测试多线程写入[线程数:"+thread_cnt+"]"); startTime = System.currentTimeMillis(); Thread[] readthreads = new Thread[thread_cnt]; for (int i = 0; i < readthreads.length; i++) { readthreads[i] = new Thread(new TestThread(false)); } for (int i = 0; i< readthreads.length; i++) { readthreads[i].start(); } for(Thread thread : readthreads){ try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } endTime=System.currentTimeMillis(); //获取结束时间 interval = endTime-startTime == 0 ? 1 : endTime-startTime; tpms = (float)test_rows/interval; System.out.println("程序运行时间: "+ interval+"ms"); System.out.println("每毫秒读取:"+tpms+"条。"); System.out.println("每秒读取:"+tpms*1000+"条。"); } static class TestThread implements Runnable { private boolean readMode = true; public TestThread(boolean readMode){ this.readMode = readMode; } @Override public void run() { Jedis j = new Jedis(ip,port); j.auth(auth); for (int i = 0; i < test_rows/thread_cnt; i++) { if (this.readMode) { j.get("foo"+i); } else { j.set("foo"+i, "bar"+i); } } j.disconnect(); } } }

对比结果视图

image

结束

原本我想着redis估计得秒了ignite,毕竟redis是这么多系统正在使用的内存数据库。ignite本身含有这么多功能按理性能肯定是比不上才对,而且ignite组成集群后是需要进行数据分块存取和备份的,而测试环境中redis则是单实例情况,这让我没太想明白啊。。还望有高手指点。。

看网上许多人测试的数据redis少点的4万+,据说可以到10万+。但我自己的测试环境差了点反正最多也没过3万,这到底会是什么原因呢?

不管如何这是一次简单的测试与尝试,结果与预期有点偏差,继续学习深入了解吧。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/07c00b5156f3a55d80b9ef14b362e720.html