Windowsでのredisとmemcachedのパフォーマンス比較テスト


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コード:
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) {
				
			}
		}
		
	}
}