Advertisement
Intermediate Redis, Redis Performance Tuning & Benchmarking

What common commands and usage patterns should generally be avoided because they can cause performance problems on a large Redis dataset?

Short answer

You should avoid the KEYS command in favor of SCAN, avoid retrieving an entire very large collection at once when only a portion is actually needed, avoid storing extremely large individual values that take a long time to transfer and process, and avoid running expensive…

Save Redis mock interview
Advertisement
AModel answer
You should avoid the KEYS command in favor of SCAN, avoid retrieving an entire very large collection at once when only a portion is actually needed, avoid storing extremely large individual values that take a long time to transfer and process, and avoid running expensive operations like sorting a huge collection frequently without caching the result.
Example

-- Avoid on a large dataset KEYS * -- Prefer this instead SCAN 0 COUNT 100

Real-world example
A team notices periodic latency spikes correlate exactly with a monitoring script's scheduled run, discovering it was using KEYS on a large production dataset, and fixes the issue by switching it to SCAN.
Likely follow-ups
  • What other Redis commands have similar performance characteristics to KEYS that should be used carefully?
  • How do you identify which specific commands are causing performance issues in your application?
Related topics