Video in progress

Do you run Redis yourself inside Kubernetes or take a managed service (ElastiCache, Memorystore and others)? How do you justify the decision?

I usually prefer a managed service: failover, patching, backup and monitoring are ready, and there's less on-call load. Running it ourselves on Kubernetes makes sense where there's no managed option (on-prem), when cost is very important, or for a pure cache that's fine to lose, but then you need to know the subtle points of the operator and the StatefulSet.

📖 Answer

The question isn't really about technology, it's about who gets up at night.

A managed service:

  • automatic failover, Multi-AZ, version upgrades, snapshots;
  • monitoring and alerts come ready;
  • the price is usually 1.5-3 times more than raw VMs;
  • limits: some commands and settings are closed off (CONFIG partially), the choice of modules is limited, versions follow the provider's schedule;
  • license: many providers now offer Valkey.

Running it ourselves on Kubernetes:

  • a Bitnami chart or an operator (for example, Redis operators, the Valkey operator);
  • StatefulSet, PVC, PodDisruptionBudget, anti-affinity, so replicas don't land on the same node;
  • subtle points:
    • a pod's IP changes on restart, so the cluster/Sentinel configuration must be set up correctly with hostnames or an announced IP (cluster-announce-ip);
    • the gap between the memory limit and maxmemory: if you don't leave headroom for fork/CoW and output buffers, you get OOMKilled;
    • Transparent Huge Pages and vm.overcommit_memory are set at the node level; they can't be set from pods, so you need an init container or node configuration;
    • with persistence, PVC speed and zone binding (a pod can't move to another zone);
    • if the master pod is killed during a node drain, writes fail for the duration of the failover.

My decision criteria:

  1. Does the organization have a platform team that can support this service 24/7?
  2. The data type: for a pure cache (fine to lose), a simple deploy on Kubernetes with one or two replicas is enough. For sessions, locks and queues, managed.
  3. The price difference and the volume: at small volume managed is cheaper (once you count engineering time), at very large volume running it yourself may make economic sense.
  4. Regulatory requirements: in some government or bank systems the data must stay in your own data center, and then there's no choice, it's on-prem.

In many places the end state is mixed: the important Redis instances are managed, and the temporary in-service caches run on Kubernetes as a sidecar or a small deployment.