1 of 8

Redis Cluster

Cluster, Version, Tips

eZ Conference 2018

Version 0.1

2 of 8

Understanding Redis setups

3 of 8

Simple Server and Master Slave

01

Slave configuration:

/etc/redis/redis.conf this Redis server an exact copy of a master server# slaveof <masterip> <masterport>�slaveof localhost 6379�# setting a slave to authenticate to a master�masterauth mypass

Master configuration:

requirepass mypass

Get replication information: redis-cli -p 6379 -a mypass info replication

Stop replication and turning slave into a master: redis-cli -p 6380 slaveof no one

4 of 8

Redis Cluster

02

=> Manual configuration

  • Master - Slave
  • Sharding your data among nodes

Redis Cluster is not able to guarantee strong consistency. In practical terms this means that under certain conditions it is possible that Redis Cluster will lose writes that were acknowledged by the system to the client.

This means that during writes the following happens:

  • Your client writes to the master B.
  • The master B replies OK to your client.
  • The master B propagates the write to its slaves B1, B2 and B3.

As you can see B does not wait for an acknowledge from B1, B2, B3 before replying to the client

5 of 8

Redis Cluster with Sentinel

03

Configuration example:

sentinel monitor mymaster redis-master 6379 $SENTINEL_QUORUM

sentinel down-after-milliseconds mymaster $SENTINEL_DOWN_AFTER

sentinel parallel-syncs mymaster 1

sentinel failover-timeout mymaster $SENTINEL_FAILOVER

The quorum is the number of Sentinels that need to agree about the fact the master is not reachable, in order for really mark the slave as failing, and eventually start a failover procedure if possible.

*Minimal numbers of Sentinel servers to be effective: 3

6 of 8

Create your own Redis Cluster Sentinel with Docker

7 of 8

HaProxy and Redis cluster auto-discovery ?

HashiCorp Consul: Service discovery and configuration made easy (https://www.consul.io/)

GliderLabs Registrator: Swatches for new Docker containers and inspects them to determine what services they provide. (http://gliderlabs.github.io/registrator/latest/)

HashiCorp Consul-template: queries a Consul instance and updates any number of specified templates on the filesystem. As an added bonus, Consul Template can execute arbitrary commands when a template update completes. (https://www.hashicorp.com/blog/introducing-consul-template)

01 | Service discovery

02 | Failure detection

03 | Multi datacenter

04 | KV storage

01 | Consul support

02 | Etcd support

03 | Sky DNS 2 support

8 of 8

Demo