Package: disredis
========================Distributed Redis client========================Distributed Redis Client (disredis) to enable real-time failover ofredis masters to paired slaves, providing improved availability and reliabilitywhere needed.The DisredisClient class can be used in place of a StrictRedis client.Instead of passing the host and port in, pass in a list of Sentinel addresses inthe form of "host:port". It will connect to the first responding Sentineland query it for masters that it knows about. These masters will become thenodes that are sharded across. As long as the number of masters does notchange, the sharding will be stable even if there is a node failure.Node failures are handled by asking the Sentinel for the updated master ofthe given node. During the initial failure, some requests may error outwith a ConnectionError if they are made between when the node fails andwhen Sentinel executes the fail-over procedure.Redis and Sentinel Configuration================================We recommend using at least Redis version 2.6.13.For testing you need a minimum of two sentinels and two redis instances(one master and one slave) to test fail over.For production we recommend at least two servers. Each server should runtwo sentinels and at least one master and one slave redis instance,running on opposite servers.::|   Server One   |    |   Server Two   ||----------------|    |----------------|| Sentinel01     |    | Sentinel03     || Sentinel02     |    | Sentinel04     || Redis01-Master |    | Redis01-Slave  || Redis02-Slave  |    | Redis02-Master || ...            |    | ...            |**Important:** If you are running on AWS please ensure your django serverscan connect to the internal IP of the AWS redis servers. AWS ec2 instancesresolve to their internal IP which results in sentinels returning theinternal IP when queried. To check the IP address of redis instances runthe following command:redis-cli -p <SENTINEL PORT, e.g. 26379> sentinel mastersExample Sentinel Configuration:port  26379 #Sentinel Portsentinel monitor redis-Redis1 server1.com 6382 2sentinel down-after-milliseconds redis-Redis1 60000sentinel failover-timeout redis-Redis1 900000sentinel can-failover redis-Redis1 yessentinel parallel-syncs redis-Redis1 1sentinel monitor redis-Redis2 server2.com 6383 2sentinel down-after-milliseconds redis-Redis2 60000sentinel failover-timeout redis-Redis2 900000sentinel can-failover redis-Redis2 yessentinel parallel-syncs redis-Redis2 1Please check the redis documentation for more details on Redis andSentinel installation and configuration.We also recommend using Supervisor or similar to manage the variousRedis and Sentinel instances.Django Setup============Either download from github and runpython setup.py installorpip install disredisAdd the disredis code to the django app.Add the following to django settingsSESSION_COOKIE_AGE = 2592000 # thirty days - Adjust to your needsSESSION_REDIS_PREFIX = '<REPLACE - e.g. mysessions>'SESSION_REDIS_HOST = 'localhost'SESSION_REDIS_DB = 6SESSION_ENGINE = 'disredis_sessions.session'SESSION_REDIS_SENTINEL_URLS = ['SENTINEL_SERVER:SENTINEL_PORT',...]Restart django to start using Redis for user sessionsTroubleshooting===============Ensure the django application servers can connect to the redisand sentinel ports.Run the following command on the redis servers to check allredis instances are listed (check IP and master/slave status):$ redis-cli -p <SENTINEL PORT, e.g. 26379> sentinel master