Skip to main content
K8sCalc

kubernetes

Redis Kubernetes Memory Calculator

Calculate how much memory your Redis deployment needs on Kubernetes. Accounts for dataset size, replication, overhead, and Redis Cluster mode.

Sizing Redis on Kubernetes

Redis is an in-memory data store — all data lives in RAM. Correct memory sizing is critical: too little triggers OOM kills; too much wastes compute cost.

Memory Formula

per_replica_memory = dataset_size × (1 + overhead_pct)
total_memory = per_replica_memory × replicas × cluster_factor

Where cluster_factor = 1.1 for Redis Cluster, 1.0 for standalone.

Key Redis Memory Patterns

Use CaseOverheadEviction Policy
Cache (ephemeral)20–30%allkeys-lru
Session store30–50%noeviction
Pub/Sub broker20%noeviction
Sorted sets / leaderboards50–100%volatile-lru

Kubernetes Pod Configuration

yaml
resources:
  requests:
    memory: "8Gi"    # from calculator
  limits:
    memory: "10Gi"   # 1.2× request
env:
  - name: REDIS_ARGS
    value: "--maxmemory 8192mb --maxmemory-policy allkeys-lru"

Redis Sentinel vs Redis Cluster

SentinelCluster
ShardingNo — single datasetYes — hash slots
FailoverAutomaticAutomatic
Max datasetSingle node RAMN × node RAM
ComplexityLowHigh
K8s operatorredis-operatorredis-operator (cluster mode)

Frequently Asked Questions

Why does Redis use more memory than my raw data size?

Redis stores each value with metadata — key expiry, type information, encoding, and a pointer. A string 'hello' (5 bytes) might occupy 60–80 bytes in Redis memory. For datasets with many small keys, overhead can be 30–100% of raw data size. Use OBJECT ENCODING <key> to inspect how Redis is storing individual values.

How do I set maxmemory in a Kubernetes Pod?

Set maxmemory in redis.conf or pass it as a flag: redis-server --maxmemory 8gb --maxmemory-policy allkeys-lru. Always set maxmemory to ~80% of your container memory limit — this leaves headroom for the Redis process itself and prevents OOM kills. The calculator's maxmemory output already accounts for this.

Do Redis replicas double my memory usage?

Yes — each replica holds a full copy of the dataset. 3 replicas (1 primary + 2 replicas) triple your memory usage. The tradeoff is high availability: replicas allow failover without data loss if the primary crashes. For pure caching where data loss is acceptable, replicas are optional.

What is Redis Cluster mode and when do I need it?

Redis Cluster shards data across multiple primary nodes using hash slots. It's needed when your dataset is too large for a single node, or when you need horizontal write scalability. For most use cases under ~50GB, a single primary with replicas (Sentinel) is simpler and sufficient. Redis Cluster adds operational complexity and does not support all Redis commands.

Related Tools

Related Guides