NOTE

3.5 Redis bigkey

Big keys concern Redis values that occupy substantial space. These notes record identification methods and thresholds by data type.

Redis / CacheCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. What Is a Big Key?

  • The size refers to the value:
    • string type: generally considered big when it exceeds 10 KB;
    • other types: too many elements.

2. Risks of a Big Key

  • Timeout and blocking: operating on a big key is time-consuming.
  • Uneven memory allocation: for example, under Redis Cluster mode.
  • Is the bottleneck for reading/writing a big key CPU or bandwidth? When bandwidth is below xx, bandwidth is exhausted first; above xx, the CPU reaches full utilization first.

3. How to Find a Big Key

  • scan + debug object: on a replica node, use scan for incremental scanning, then use debug object to calculate whether each key’s serializedlength attribute is too large.
  • redis-cli provides --bigkeys, for example: redis-cli -h <hostip> -a <password> --bigkeys.

4. How to Delete a Big Key

  • string: use del.
  • others: hscan + hdel + del.

5. How to Handle a Big Key

5.1. Split It into Smaller Keys

6. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub