Predis: Pros and Cons of the two cluster strategies

849 views Asked by At

I am using Predis to connect to a Redis 3.0.2 cluster. So, I have an option to use either predis or redis cluster strategy. I am wondering if there are any significant pros and cons of choosing one of them over the other?

Based on my wandering through documentation, I have these couple of points in my mind, but I am not sure if my understanding is correct:

  1. When using redis strategy, we don't have to list every node of our cluster while establishing a connection. Reference (Possibly a pro :) )

    When using redis-cluster, it is not necessary to pass all of the nodes that compose your cluster but you can simply specify only a few nodes

  2. Next line of the article linked above says:

    Predis will automatically fetch the full and updated slots map directly from Redis by contacting one of the servers.

Could it be a con in terms of performance? Because Predis will need to fetch some data from server before deciding which node to select for current read/write operation?

Context:

We are planning to use Redis to store PHP sessions. It is an AJAX heavy web application with thousands of active users at peak times. That's why we want to spread load across multiple Redis nodes. We will be happy to manually maintain the list of server addresses in connection establishment code in order to use predis strategy if it is expected to offer significantly better performance as compared to redis strategy for this specific use case.

1

There are 1 answers

0
Itamar Haber On BEST ANSWER

IIUC you're debating internally between using Predis' client-side sharding vs. having it leverage Redis v3's clustering abilities.

Client-side sharding is a great to have clustering when a database doesn't support it and this approach is usually the easiest implement initially. However, when a database does provide native clustering functionality - as is the case with Redis v3 - you'd almost always be better off using that.

In terms of performance, I'm not really sure whether there's any significant difference between the approaches. Redis partitioning is also discussed at http://redis.io/topics/partitioning