修改本页

Redis 命令 客户端 文档 社区 下载 问题 支持 许可

MONITOR

相关命令

始于1.0.0可用。

MONITOR is a debugging command that streams back every command processed by the Redis server. It can help in understanding what is happening to the database. This command can both be used via redis-cli and via telnet.

The ability to see all the requests processed by the server is useful in order to spot bugs in an application both when using Redis as a database and as a distributed caching system.

  1. $ redis-cli monitor
  2. 1339518083.107412 [0 127.0.0.1:60866] "keys" "*"
  3. 1339518087.877697 [0 127.0.0.1:60866] "dbsize"
  4. 1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6"
  5. 1339518096.506257 [0 127.0.0.1:60866] "get" "x"
  6. 1339518099.363765 [0 127.0.0.1:60866] "del" "x"
  7. 1339518100.544926 [0 127.0.0.1:60866] "get" "x"

Use SIGINT (Ctrl-C) to stop a MONITOR stream running via redis-cli.

  1. $ telnet localhost 6379
  2. Trying 127.0.0.1...
  3. Connected to localhost.
  4. Escape character is '^]'.
  5. MONITOR
  6. +OK
  7. +1339518083.107412 [0 127.0.0.1:60866] "keys" "*"
  8. +1339518087.877697 [0 127.0.0.1:60866] "dbsize"
  9. +1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6"
  10. +1339518096.506257 [0 127.0.0.1:60866] "get" "x"
  11. +1339518099.363765 [0 127.0.0.1:60866] "del" "x"
  12. +1339518100.544926 [0 127.0.0.1:60866] "get" "x"
  13. QUIT
  14. +OK
  15. Connection closed by foreign host.

Manually issue the QUIT command to stop a MONITOR stream running via telnet.

Cost of running MONITOR

Because MONITOR streams back all commands, its use comes at a cost. The following (totally unscientific) benchmark numbers illustrate what the cost of running MONITOR can be.

Benchmark result without MONITOR running:

  1. $ src/redis-benchmark -c 10 -n 100000 -q
  2. PING_INLINE: 101936.80 requests per second
  3. PING_BULK: 102880.66 requests per second
  4. SET: 95419.85 requests per second
  5. GET: 104275.29 requests per second
  6. INCR: 93283.58 requests per second

Benchmark result with MONITOR running (redis-cli monitor > /dev/null):

  1. $ src/redis-benchmark -c 10 -n 100000 -q
  2. PING_INLINE: 58479.53 requests per second
  3. PING_BULK: 59136.61 requests per second
  4. SET: 41823.50 requests per second
  5. GET: 45330.91 requests per second
  6. INCR: 41771.09 requests per second

In this particular case, running a single MONITOR client can reduce the throughput by more than 50%. Running more MONITOR clients will reduce throughput even more.

返回值

Non standard return value, just dumps the received commands in an infinite flow.

Comments powered by Disqus

This website is open source software developed by Citrusbyte.

The Redis logo was designed by Carlos Prioglio. See more credits.

Sponsored by Redis Support