2

I have been using redis stand alone for many years now. Since now the requirement is that all software must be clustered to make it highly-available I am evaluating redis-cluster.

When I try a simple rpush on a single redis key , the cluster takes 5x more the time for rpush as compared to a standalone instance

Is there something I should be doing to improve the performance of the cluster. The redis server version is 3.2.3

The code is below ( php)

<?php
$redis_standalone = new Redis();
$redis_standalone->connect("localhost");
$redis_standalone->del("JOBS_QUEUE");
echo time()."\n";
for($i=0;$i<100000;$i++){
        $redis_standalone->rpush("JOBS_QUEUE",$i);
}
echo time()."\n";
?>

And for the cluster

<?php
$redis_cluster = new RedisCluster('myclustername', ['127.0.0.1:7000','192.168.50.166:7001','192.168.50.167:7000','192.168.50.168:7000','192.168.50.169:7000','192.168.50.171:7000']);
$redis_cluster->del("JOBS_QUEUE");
echo time()."\n";
for($i=0;$i<100000;$i++){
        $redis_cluster->rpush("JOBS_QUEUE",$i);
}
echo time()."\n";
?>
Ram
  • 1,155
  • 13
  • 34
  • 1
    I think you should make another test where the single redis instance is located on another host on the network. Making the test on loopback interface doesn't really take consideration of network latency. You could re-test the cluster where all nodes are connected on local loopback. However, either way, you wouldn't see any difference in performance as "JOBS_QUEUE" will be located on a single node no matter in single mode nor cluster mode. – Redisson_RuiGu Jul 03 '17 at 11:06
  • Seems correct. When I run the standalone script also from remote I get similar performance. The only thing is that my app used to connect to redis@localhost , now that will connect to cluster and that is bound to be slower :( Seems strange , if you add hardware performance should actually increase but here it goes down, just because I am planning for redundancy – Ram Jul 03 '17 at 14:44
  • The thing you have to remember is you are gaining high availability by shifting from a single instance to bunch of cluster instance, and of course, like everything else in life, there is a price to pay. You have to always remember redis stands for REmote DIctionary Server, it truly shines when it is at a remote location. And take my word, if that rps number really bothers you, try and run the redis on a unix domain socket. – Redisson_RuiGu Jul 03 '17 at 21:17
  • Same observations using Jedis driver for redis. Standalone always performs better than cluster performance. 100k RPUSH in a single thread on same KEY – Kedar Parikh Jul 06 '17 at 10:16
  • @Redisson_RuiGu Could you tell why redis would perform better on unix domain socket? – Anirudh Jayakumar Sep 20 '17 at 18:35
  • @AnirudhJayakumar please refer to https://stackoverflow.com/questions/14973942/performance-tcp-loopback-connection-vs-unix-domain-socket – Redisson_RuiGu Sep 22 '17 at 08:48

0 Answers0