How to use Redis on production

172 views
Skip to first unread message

Abhishek Tiwari

unread,
Aug 20, 2015, 3:27:52 AM8/20/15
to Redis DB
How should we use redis on production 

a) cluster mode 
b) Master -slave 

We are using phpredis  client .



Itamar Haber

unread,
Aug 20, 2015, 3:47:09 AM8/20/15
to redi...@googlegroups.com

Please expand.

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Abhishek Tiwari

unread,
Aug 20, 2015, 5:15:13 AM8/20/15
to Redis DB
hi Itamar,

I am using phpredis client  and tested the feature . This working fine on local machine .
Now i have to go live with this feature  ,  we are high traffic website so we need multiple redis instances .
in that case should i use  RedisArray to create object or Rediscluster
In case of RedisArray when we any of the node goes down it gives me  
( ! ) Fatal error: Uncaught exception 'RedisException' with message 'Connection closed'  

Itamar Haber

unread,
Aug 20, 2015, 8:02:11 AM8/20/15
to redi...@googlegroups.com
Redis Cluster is a tool to for tackling scaling challenges. Master-Slave is for high availability and/or read scaling. From your description it appears that you want high availability to prevent the denial of service in the event of node failure. There are several ways to do that with Redis, the most common is using Sentinel to manager your replication sets (pods). Depending on your definition of "high traffic", you may need to cluster as well.

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--

Itamar Haber | Chief Developer Advocate & Senior Solution Architect
Redis Watch Newsletter - Curator and Janitor
Redis Labs - Enterprise-Class Redis for Developers

Mobile: +1 (415) 688 2443
Office: +1 (650) 396 2999 Ext. 123
Mobile (IL): +972 (54) 567 9692
Office (IL): +972 (3) 720 8515 Ext. 123
Email: ita...@redislabs.com
Twitter: @itamarhaber
Skype: itamar.haber

Blog  |  Twitter  |  LinkedIn


Abhishek Tiwari

unread,
Aug 21, 2015, 6:32:48 AM8/21/15
to Redis DB
Thanks for reply . Need more clarity 
Hi 

We have setup a cluster say host1, host2, host3 ,host4 for production and using phpredis client .

my questions is following 
a)  should i put host1,host2,host3,host4 behind load balancer on production ?  
and connect like below
$redisObj = new Redis(); 
 $redisObj->pconnect('load balencer IP', 'Port', 2);


OR

b)  we have to connect like this 

$obj_cluster = new RedisCluster(NULL, Array('host1:6379', 'host2:6379','host3:6379','host4:6379'));
    $obj_cluster->ping();


 


On Thursday, August 20, 2015 at 12:57:52 PM UTC+5:30, Abhishek Tiwari wrote:

Itamar Haber

unread,
Aug 21, 2015, 7:18:29 AM8/21/15
to redi...@googlegroups.com
I'm not a phpredis guru, but if you've set up a Redis v3 cluster on these nodes, it looks like b) is the way to go (according to https://github.com/phpredis/phpredis/blob/develop/cluster.markdown).

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Abhishek Tiwari

unread,
Sep 1, 2015, 8:10:04 AM9/1/15
to Redis DB
Thanks ,

I have to run Keys command over cluster (twemproxy) . Is it possible to do it .
My use case is to delete all the keys that are matching 
a) Product_*
b) Blocks_*

How can i do it over cluster environment ? 
Or if this is not possible to do to then is there any way to delete pattern matched keys.


Regards,
Abhishek

Matt Silverlock

unread,
Sep 2, 2015, 12:28:21 AM9/2/15
to Redis DB
Look at using SCAN ... MATCH %pattern% as per http://redis.io/commands/scan - and iterate over the cursor until it hits 0. Avoid using KEYS * in production as it's a significant performance hit.

Also consider the way your data is structured—do you need to manually delete things? Can expiring (via EXPIRES or SETEX) help you? What about your data structures (hashes, sorted sets) - can you simply run a MULTI over a series of hashes where you already know the keys and avoid having to pattern match? Not all solutions may fit but worth thinking about.

Josiah Carlson

unread,
Sep 3, 2015, 12:10:46 AM9/3/15
to redi...@googlegroups.com
You will have to directly access your Redis servers, not through Twemproxy.

 - Josiah

Reply all
Reply to author
Forward
0 new messages