Skip to main content

Scaling

Replication/Clustering

Default: Master-Slave

When installing the chart withcluster.enabled=true, it will deploy a Redis master StatefulSet (only one master node allowed) and a Redis slave StatefulSet. The slaves will be read-replicas of the master. Two services will be exposed:

  • Redis Master service: Points to the master, where read-write operations can be performed
  • Redis Slave service: Points to the slaves, where only read operations are allowed.

In case the master crashes, the slaves will wait until the master node is respawned again by the Kubernetes Controller Manager.

Master-Slave with Sentinel

When installing the chart with cluster.enabled=true and sentinel.enabled=true, it will deploy a Redis master StatefulSet (only one master allowed) and a Redis slave StatefulSet. In this case, the pods will contain en extra container with Redis Sentinel. This container will form a cluster of Redis Sentinel nodes, which will promote a new master in case the actual one fails. In addition to this, only one service is exposed:

  • Redis service: Exposes port 6379 for Redis read-only operations and port 26379 for accesing Redis Sentinel.

For read-only operations, access the service using port 6379. For write operations, it's necessary to access the Redis Sentinel cluster and query the current master using the command below (using redis-cli or similar:

SENTINEL get-master-addr-by-name mymaster

This command will return the address of the current master, which can be accessed from inside the cluster.

In case the current master crashes, the Sentinel containers will elect a new master node.

https://redis.io/topics/sentinel

Redis Cluster

https://redis.io/topics/cluster-tutorial

https://redis.io/topics/cluster-spec

Replication - One leader many followers model

Clustering - Shard data across multiple nodes

https://redis.io/topics/cluster-tutorial

Hybrid - Replication + Clustering

Sentinel - https://redis.io/topics/sentinel

keydb - Multithreaded fork of redis

https://docs.keydb.dev/blog/2019/10/07/blog-post

twenproxy (by twitter)

twemproxy (pronounced "two-em-proxy"), aka nutcracker is a fast and lightweight proxy for memcached and redis protocol. It was built primarily to reduce the number of connections to the caching servers on the backend. This, together with protocol pipelining and sharding enables you to horizontally scale your distributed caching architecture.

https://github.com/twitter/twemproxy

codis

Proxy based Redis cluster solution supporting pipeline and scaling dynamically

image

https://github.com/CodisLabs/codis

CodisTwemproxyRedis Cluster
resharding without restarting clusterYesNoYes
pipelineYesYesNo
hash tags for multi-key operationsYesYesYes
multi-key operations while reshardingYes-No(details)
Redis clients supportingAny clientsAny clientsClients have to support cluster protocol

Redis vs Memcached

Both Redis and MemCached are in-memory, open-source data stores. Memcached, a high-performance distributed memory cache service, is designed for simplicity while Redis offers a rich set of features that make it effective for a wide range of use cases.

MemcachedRedis
Sub-millisecond latencyYesYes
Developer ease of useYesYes
Data partitioningYesYes
Support for a broad set of programming languagesYesYes
Advanced data structures-Yes
Multithreaded architectureYes-
Snapshots-Yes
Replication-Yes
Transactions-Yes
Pub/Sub-Yes
Lua scripting-Yes
Geospatial support-Yes

https://aws.amazon.com/elasticache/redis-vs-memcached

Memcached Tutorial for Beginners - YouTube

DragonFly

Dragonfly is a drop-in Redis replacement, designed to meet the performance and efficiency requirements of modern cloud-based applications. Organizations that switch to Dragonfly require less hardware and achieve dramatically improved data performance.

Other in-memory database

  1. facebook rocksdb
  2. memcached - Memcached Architecture - Crash Course with Docker, Telnet, NodeJS - YouTube
  3. GitHub - paypal/junodb: JunoDB is PayPal's home-grown secure, consistent and highly available key-value store providing low, single digit millisecond, latency at any scale.
  4. Dissecting Juno DB - YouTube
  5. Aerospike