2

form many blog, i learn that the redis command keys * may block the redis server, and other command can not be execute on time .

however, today i run the keys * on my db which has about 8million data. and then i use my other client to exec other command like get or set, this all work well, and give response on time.

so, i'm confused that why my command keys not block.

the picture is https://i.stack.imgur.com/8flt4.png

Lucas gao
  • 23
  • 4

2 Answers2

5

KEYS (and almost any other Redis command for that matter) is blocking, do not be fooled :)

While Redis is scanning its internal dictionary and assembling the response, it is blocked. However, after the response is ready and moved to the network layer, the server is free to process the next operations. Your client, in the meanwhile, is blocked from the time it sent KEYS until the entire response is received by it.

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117
0

The interesting fact about blocking commands is that they do not block the whole server, but just the client calling them. Source: https://redis.io/docs/reference/modules/modules-blocking-ops/