教程 > Redis教程 > Redis 命令 阅读:21

Redis MONITOR 命令

Redis MONITOR 命令

返回 Redis 服务器


Redis MONITOR 命令用于实时打印出 Redis 服务器接收到的命令,调试用。

语法

redis Monitor 命令基本语法如下:

redis 127.0.0.1:6379> MONITOR

可用版本

>= 1.0.0

返回值

总是返回 OK 。

实例

redis 127.0.0.1:6379> MONITOR 
OK
1410855382.370791 [0 127.0.0.1:60581] "info"
1410855404.062722 [0 127.0.0.1:60581] "get" "a"

MONITOR 不记录的命令

处于安全方面的考虑,所有的管理相关的命令不会记录到 MONITOR 的输出者。

下面几个命令也不会记录:

  • AUTH
  • EXEC
  • HELLO
  • QUIT

MONITOR 的消耗

因为 MONITOR 流返回所有命令,所以用起来会有一定的消耗。 下面是一个基准测试对比:

不带 MONITOR 命令:

$ src/redis-benchmark -c 10 -n 100000 -q
PING_INLINE: 101936.80 requests per second
PING_BULK: 102880.66 requests per second
SET: 95419.85 requests per second
GET: 104275.29 requests per second
INCR: 93283.58 requests per second

带 MONITOR 命令 (redis-cli monitor > /dev/null):

$ src/redis-benchmark -c 10 -n 100000 -q
PING_INLINE: 58479.53 requests per second
PING_BULK: 59136.61 requests per second
SET: 41823.50 requests per second
GET: 45330.91 requests per second
INCR: 41771.09 requests per second

通过上面的例子可以看到运行一个 MONITOR 命令降低了超过 50% 的吞吐量。 运行多个 MONITOR 会进一步降低性能。

返回 Redis 服务器

查看笔记

扫码一下
查看教程更方便