Skip to main content
========================
Distributed Redis client
========================

Distributed Redis Client (disredis) to enable real-time failover of
redis masters to paired slaves, providing improved availability and reliability
where 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 in
the form of "host:port". It will connect to the first responding Sentinel
and query it for masters that it knows about. These masters will become the
nodes that are sharded across. As long as the number of masters does not
change, the sharding will be stable even if there is a node failure.

Node failures are handled by asking the Sentinel for the updated master of
the given node. During the initial failure, some requests may error out
with a ConnectionError if they are made between when the node fails and
when 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 run
two 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 servers
can connect to the internal IP of the AWS redis servers. AWS ec2 instances
resolve to their internal IP which results in sentinels returning the
internal IP when queried. To check the IP address of redis instances run
the following command:

redis-cli -p <SENTINEL PORT, e.g. 26379> sentinel masters

Example Sentinel Configuration:

port 26379 #Sentinel Port

sentinel monitor redis-Redis1 server1.com 6382 2
sentinel down-after-milliseconds redis-Redis1 60000
sentinel failover-timeout redis-Redis1 900000
sentinel can-failover redis-Redis1 yes
sentinel parallel-syncs redis-Redis1 1

sentinel monitor redis-Redis2 server2.com 6383 2
sentinel down-after-milliseconds redis-Redis2 60000
sentinel failover-timeout redis-Redis2 900000
sentinel can-failover redis-Redis2 yes
sentinel parallel-syncs redis-Redis2 1

Please check the redis documentation for more details on Redis and
Sentinel installation and configuration.

We also recommend using Supervisor or similar to manage the various
Redis and Sentinel instances.

Django Setup
============

Either download from github and run

python setup.py install

or

pip install disredis

Add the disredis code to the django app.

Add the following to django settings

SESSION_COOKIE_AGE = 2592000 # thirty days - Adjust to your needs

SESSION_REDIS_PREFIX = '<REPLACE - e.g. mysessions>'
SESSION_REDIS_HOST = 'localhost'
SESSION_REDIS_DB = 6

SESSION_ENGINE = 'disredis_sessions.session'

SESSION_REDIS_SENTINEL_URLS = [
'SENTINEL_SERVER:SENTINEL_PORT',
...]

Restart django to start using Redis for user sessions

Troubleshooting
===============

Ensure the django application servers can connect to the redis
and sentinel ports.

Run the following command on the redis servers to check all
redis instances are listed (check IP and master/slave status):

$ redis-cli -p <SENTINEL PORT, e.g. 26379> sentinel master

Metadata

Release files for disredis 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for disredis 1.0
File Size Uploaded Provenance Actions
disredis-1.0.tar.gz 13.2 kB Without provenance Details for disredis-1.0.tar.gz

Release files / disredis-1.0.tar.gz

Download URL disredis-1.0.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
eb4527929e3ca2c4f1a4ae54b0f8829579605121f83edcaa86f584b1f7b5ce21
BLAKE2b-256 checksum
How to use checksums
b247bfc1d031f3e72e8d1e25801c4c8e5bd1483c327e7af407257ada2820c7b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for disredis 1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page