I want to use Redis RPUSH and LPOP as message queue in my project, and now I encountered a performance problem:
When I simply rpush a random Double nubmer using Jredis with a single thread from my java client, I notice that the throughout is just 4000 request/secs, which is much lower than what I expected.
Here is my redis Configuration:
timeout 300
save 900 1
save 300 10
save 60 10000
no memory limit with 4G memory.
and Java snippet:
jredis = new JRedisClient(ip,6379);
long bytesTransfered = 0;
Date start = new Date();
for(int i = 0; i < 100000 ; i ++){
String s = Math.random()+"";
jredis.lpush("testqueue", s);
bytesTransfered += s.length();
}
Date end = new Date();
double seconds = (end.getTime() - start.getTime())/1000f;
System.out.println("REDIS:\t"+ (bytesTransfered/seconds)+"bytes/second,\t"+100000/seconds+"request/second");
Is there any other java client better than jredis? Thanks for your help!.
Try some tests without java – the client included with redis should do. There may be some overhead in the java client, but your issue is most likely the network connection. The network may be able to transfer large amounts of data fast, but lots of small keys gets you worst case performance for overhead and latency.
Your test has each operation happening synchronously, waiting for a response before sending the next command. Both client and server can handle more in normal usage – start another thread/connection and you will probably get much better numbers.