Enabling Redis For Your App - Archived

Recently, OpenShift announced support for community-contributed cartridges. This way we again push the envelope of openness of the PaaS systems one level further and prove that PaaS systems do not have to be lock-in nightmares for your company.

Redis is one of the most requested features of OpenShift users. Even though Redis is still not “officially” supported, you can easily use deploy it with the community contributed cartridge.

What does that mean? At Red Hat, we strongly believe that we should provide an exceptional service and thus we can not push new features into the production “like crazy” because all the pieces need to be well-tested and got to go through a rigorous review.

On the other hand, we strive to be as open and extensible as possible by giving OpenShift users the means (cartridges) to extend OpenShift to get what they need when they want it by collaborating as a community. Even though Red Hat does not yet have an officially supported Redis cartridge for you, we are here to provide you with a stable and super-secure environment where you can actually run Redis via the community-contributed cartridge. And running Redis this way is not a difficult task at all.

What is Redis?

Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

Redis is a NoSQL in-memory data-store with support for complex use-cases and querying. One of the benefits of Redis is it’s crazy speed, thus people do use it as a caching component (e.g. replacement for Mamcache), however Redis (compared to Memcache) provides features that make it well-capable database application compared to “dumb” key value store Memcache is.

Redis Use Cases

Caching is one of the simplest things to use Redis for. Most frameworks provide drivers for Redis and allow to be configured to use Redis as a caching store.

Redis as cache for Ruby frameworks

Redis as cache for Django

Radis as cache for Servlets

Analytics may be done using Redis. Redis’s data-structures allow you to use the database for building real-time analytics systems.

Minuteman – Fast analytics using Redis

Crashalytics – user-story

Redis may be used as a Message queue. Whenever you need to pass some events among a distributed system you may consider Redis as an option. One specific-use case that Redis is very much used for is out-of-process task execution. When your web application needs to do some intensive task, it pushes information about it to Redis and some worker component gets the “job” from there.


General purpose data store is also possible.

A case study: Design and implementation of a simple Twitter clone using only the Redis key-value store as database and PHP

Redis as the primary data store? WTF?!

And many more, like 11 Common Web Use Cases Solved In Redis.

Getting started

Go to the Download page on the Redis website and download the distribution for your system. You may also use your favorite package manager to install Redis

yum install redis
apt-get install redis
brew install redis

Once you have Redis installed, start the server. It might have been done by your package manager, or you can do it manually


when the server is started we can connected to it and start using it.


Now, you can operate Redis from the command line tool.

Key-value store

Let’s see how to use Redis as a simple key-value store. First, let’s set the value for key “openshift” to “awesome”

SET "openshift" "awesome"

and, now, let’s read the value for the same key

GET "openshift"

and finally delete it.

DEL "openshift"

WoooHooo …. simple, isn’t it?

Message Passing

Let’s start two clients. One will wait till a message is pushed into Redis and will print it.

BRPOP "openshift" 0

After this command, you should see your client to block. Now, let’s start 2nd client, push a message,

RPUSH "openshift" "awesome"

and check the status in the 1st window.

Simple, yet effective.

If you like what you have seen, I can only recommend you to check the documentation and read more about the possibilities Redis offers. You will be also probably interested in a list of all the client libraries for Redis for your favorite language.

Redis on OpenShift

As I mentioned already, Redis is not yet officially supported on OpenShift so there are a few more steps to deploy it, however it is not complex at all! First, let’s remember how you would add a supported cartridge (e.g. postgresql)

rhc cartridge add postgresql-9.2 -a (you app name)

and now let’s deploy Redis!

rhc cartridge add "http://cartreflect-claytondev.rhcloud.com/reflect?github=smarterclayton/openshift-redis-cart" -a (your app name)

When the command finishes, you shall have Redis deployed in your gear.

** The only difference is that you can not use the “name” for the cartridge, but need to know the URL where to fetch the cartridge from.**

Testing Redis on OpenShift

To see Redis is actually deployed and working, we shall ssh into the gear.

rhc ssh (your app name)

Check the information Redis published for us.

env | grep REDIS

Finally, connect to Redis


and authenticate, you have the password available in the environment variables we printed previously. Once connected, just write

AUTH (you passowrd)

Once you hit enter you should see “+OK” as a response. Now, you can use Redis! Let’s see what my test looked like

SET "openshift" "awesome"
GET "openshift"
DEL "openshift"

Oh, I might have mention that Redis uses text-based protocol, so it’s extremely-super-simple to play with it over such a simple tool as telnet is.

Redis Cluster

Redis does support cluster-based deployments. For more information on this topic, check the Redis clustering on the Redis cartridge homepage


You are now fully equipped to use Redis on OpenShift even though the support is not yet enterprise-grade SLA supported. It’s fully functional and you can use you it for building your applications. Happy Redising!

See it for Yourself

What’s Next?

OpenShift Origin
, , , ,
Comments are closed.