Chapter 8. Redis

Redis is an open source, 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 has a very novel approach to being a datastore. Actually, its own data structure server is a very apt description: it is a server.

As with all our infrastructure components, we aim for resilience (does not break easily) and reliability (does what you expect it to do). For Redis, we have to figure out how to do the following:

  • Backup/restore
  • Failover
  • Scaling (up and down)
  • Monitoring

This project is available on github at ReDiS.

The Problem

Redis as a data structure server finds its limits in the server. The core idea is that it exposes the memory on an instance as a variety of structured data through an API. This is fast but very fragile. Memory is not persisted.

This feature has two consequences we have to deal with:

  1. Persistence (how to make backups)
  2. Replication

Both these problems would go away if Redis were available in a distributed manner. In the next chapter, we’ll see how elasticsearch elegantly solves this shortcoming. But the distributed Redis is a work in progress and we don’t know when it will be available. In the meantime, we have our own workaround.

Our Approach

Redis has the notion of master-slave replication. In Redis anything can be a master, and masters are almost completely unaware of existing slaves. A slave has only one master, which is slaveof.

This simple approach to replication ...

Get Resilience and Reliability on AWS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.