Skip to main content

A simple asyncio redis client with cluster support and a resharding cli tool.

Project description


PyPI version Build status PyPI Python Versions License Wheel

A Redis Cluster Client with a cli line tools in the spirit of redis-trib.


UNIX one liner

curl -sL | sh

You can see what the install script is doing first here.

For folks familiar with Python

cd $HOME # or anywhere you want
python3 -mvenv venv
source venv/bin/activate
pip install rcc


$ docker run -it --version
rcc, version 0.9.48


rcc started as an attempt at writing an asyncio redis-cluster aware python client. It evolved into a redis cluster tool, built on a minimal but functional redis client library.

The main asyncio redis library, aioredis does not support redis cluster at this point. There is another library named aredis which has cluster support, but which has some small bugs for which pull requests existed, that were not merged until recently. Getting a redis client to work is not terribly hard, thanks to the design of redis, so I started this project and got it to work in a limited amount of time.

Library usage

Nothing fancy. The api just uses .send to send commands and that's it, which was a great advice from Loris Cro that he is using in his Zig OkRedis client.

client = RedisClient('redis://localhost:6379')
await client.send('SET', 'foo', 'bar')
result = await client.send('GET', 'foo')


Several tools come with this package, as subcommands of the main cli named rcc. Some documentation (wip) is available here.

$ rcc
Usage: rcc [OPTIONS] COMMAND [ARGS]...

  _______   ____  ____
  \_  __ \_/ ___\/ ___\
   |  | \/\  \__\  \___
   |__|    \___  >___  >
               \/    \/

  rcc / Redis Cluster Client / cli

  --version      Show the version and exit.
  -v, --verbose
  --help         Show this message and exit.

  cli            cli tool similar to redis-cli
  cluster-check  Make sure all nodes have the same view of the cluster
  cluster-info   Monitor redis metrics from the INFO command
  cluster-init   Print a cluster init command for redis url defined in a...
  cluster-nodes  Monitor redis metrics
  endpoints      Print endpoints associated with a redis cluster service
  keyspace       Analyze the keyspace
  make-cluster   Create, configure, initialize and run a redis cluster
  migrate        Migrate one slot from a node to another one
  publish        Publish (with XADD) to a channel
  reshard        Reshard a cluster using the binpacking technique
  sub            Subscribe (with PUBSUB) to a channel
  subscribe      Subscribe (with XREAD) to a channel

The 2 remarquable tools are:

Keyspace analysis tool


The keyspace command will turn on redis keyspace notifications and tell you what your hot keys are. It will output a csv file containing a list of keys accessed by commands, with a weight representing their access frequency. The keyspace command can also parse the output of the MONITOR command with the -m option, which will not require to enable keyspace notifications.

The tool will display informations visually as well, such as the distribution of keys/commands amongst nodes. It is very helpful to know if your cluster provides good balancing, or whether you should reshard it. [849140] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [796878] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [759250] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [718014] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [409835] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [391286] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [386700] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [348391] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [341379] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎

Cluster Resharing tool

The reshard command will reshard your cluster in an optimal way based on your usage. It consumes the output of the keyspace command. It is documented in great details here and there.

Here is how the previous cluster usage distribution looks after resharding for us.

Disclaimer - the default sharding strategy works very well, and if you have many machines and keys you might be just fine. But if you do not have that many keys, and some of them are accessed with a much higher frequency than other this tool might help you a lot. This is the case for us in our usage of cobra at Machine Zone.

# each ∎ represents a count of 10615. total 5004030 [647515] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [581910] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [566576] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [562850] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [560954] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [551802] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [536849] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [499993] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ [495581] ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎


RCC is also the name of the Redwood Childrens Center. If you are looking for a great preschool in Redwood City, California, I highly recommend it.

Project details

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rcc, version 0.9.154
Filename, size File type Python version Upload date Hashes
Filename, size rcc-0.9.154-py3-none-any.whl (49.4 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page