Interview › Databases & Caching
Why are some Redis commands (KEYS, FLUSHALL) dangerous in production?
Databases & Caching · Advanced level
Answer
KEYS can block Redis by scanning the full keyspace, and FLUSHALL can delete the entire cache or datastore. In production I use SCAN/UNLINK, namespace isolation, ACL restrictions, and controlled cleanup jobs.
Technical explanation
Global hit ratio can hide bad key patterns; monitor by endpoint or key prefix where possible.
Large keys and hot keys can overload a single Redis thread or shard even when total cluster capacity looks fine.
Use SCAN and UNLINK instead of KEYS and mass DEL; restrict dangerous commands through ACLs or operational policy.
Hands-on example
Operational commands:
INFO stats
INFO memory
INFO commandstats
SLOWLOG GET 10
LATENCY LATEST
redis-cli --bigkeys -h <host> -p 6379Safe cleanup pattern:
redis-cli --scan --pattern "session:*" | while read key; do redis-cli UNLINK "$key"; donePipeline warmup in batches instead of one command per network round trip.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Databases & Caching interview questions
- What is the difference between Redis as a cache and Redis as a primary datastore?
- What is a cache hit ratio, and how do you improve it?
- How would you use Redis for rate limiting?
- How does ElastiCache provide high availability and automatic failover?
- How would you use Redis for distributed locking, and what are the caveats?
- What is the difference between Redis Sentinel and Redis Cluster?
- What is Redis Cluster, and how does sharding with hash slots work?
- What is Redis replication, and how does a replica stay in sync?