Redis

Redis is a single-threaded program.
A Redis Cluster has nodes of Redis to do all the incoming work.
Redis Cluster only has 16384 slots for keys.[1] Redis Client use the same hash algorithm to decide which slot and each node of Redis has their responsible nodes to work on. 16384 is enough for <1000 nodes Redis Cluster.

Redis use different CPUs for async opes such as snapshots or UNLINK.

Open Redis Client of your Heroku app

heroku redis:cli -a yourapp --confirm yourapp

INFO command to see status of your Redis.

> info

Some infos you should pay attention:

used_memory:3976008
used_memory_human:3.79M

keyspace_hits:2270
keyspace_misses:1229

You could also get these info separately by info memory or info stats.

Calculate your cache hit rate:

keyspace_hits / (keyspace_hits + keyspace_misses)

Aim for 90%.

All items outputed from INFO command, please refer to here.

And you can also compress what got saved into Redis to save memory!

config.cache_store = :redis_cache_store, {
  url: ENV.fetch("REDIS_URL"),
  namespace: "cache",
  expires_in: 604800, # 7 days
  compress: true,
  compress_threshold: 64.kilobytes,
  # compress things > 64K
}

  • GET
  • MGET
  • RPOPLPUSH
  • SETEX
  • LREM
  • MULTI SADD LPUSH
  • EVALSHA
  • MULTI EXPIRE HGET
  • SET
  • PUBLISH
  • DEL
  • HMSET EXPIRE
  • INCR EXPIRE
  • MULTI INCR EXPIRE
  • SCAN
  • TIME
  • MULTI SET INCR
  • HGET
  • MULTI SREM SCARD

[1]: See https://redis.io/topics/cluster-spec#overview-of-redis-cluster-main-components & https://github.com/redis/redis/issues/2576#issuecomment-101257195