Skip to content

How to use Redis well

Use it for hot data with a clear eviction policy, never as a source of truth, and use cluster mode for datasets larger than one node.

Redis best practices

  1. Set maxmemory-policy

    allkeys-lru for caches, noeviction for persistent data. Never let Redis OOM.

  2. Use specific data types

    Sorted sets for leaderboards, hashes for objects, lists for queues. Don't store JSON strings if a hash fits.

  3. Persistence is not backup

    RDB and AOF help with restart time, not with data loss. If Redis dies, you lose data written since the last snapshot.

  4. Cluster for scale

    Single Redis node is ~100 GB RAM max. Above that, use Redis Cluster to shard across nodes.

  5. Pub/Sub for ephemeral, Streams for durable

    Pub/Sub loses messages if no subscriber is connected. Streams is the durable alternative.