Database / ValKey Interview questions
Why should you avoid running the KEYS command in production?
KEYS scans the entire keyspace in a single pass on Valkey's main thread, so on a large dataset it can block every other client for a noticeable stretch of time, producing latency spikes or timeouts across the whole deployment.
# Avoid in production: KEYS user:* # Prefer: SCAN 0 MATCH user:* COUNT 100
SCAN returns a cursor and walks the keyspace incrementally in small, non-blocking batches instead, trading a slightly weaker consistency guarantee against concurrent writes for safety at scale.
More Related questions...