Redis命令队列大小 [英] Redis commands queue size

查看:73
本文介绍了Redis命令队列大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何记录/测量Redis命令队列的大小.

How to log/measure the size of Redis command's queue.

Redis是单线程的,因此它按顺序运行命令,因为我猜那里有命令队列,存储传入的命令,并逐个执行.SLOWLOG命令仅显示执行时间,所以问题是,是否有一种方法可以获取开始执行之前命令在队列中的时间.

The Redis is single-threaded, so it runs commands sequentially, as I guess there is command queue there, where the incoming commands are stored, and executed one by one. The SLOWLOG command only shows the execution time, so the question is, is there a way to get how long the command was in queue before starting of execution.

推荐答案

AFAIK,Redis中没有命令队列.

AFAIK, there is no command queue in Redis.

当套接字上有需要读取的内容时,将通知事件循环.Redis读取套接字,解析输入缓冲区并执行从输入缓冲区解码的命令.如果同时(在不同的套接字上)接收到多个命令,则它们将作为同一事件循环迭代的一部分按顺序进行处理.

The event loop is notified when there is something to read on a socket. Redis reads the socket, parses the input buffer and execute commands as they are decoded from the input buffer. If multiple commands are received at the same time (on different sockets), they are just processed in sequence as part as the same event loop iteration.

无法评估待处理命令的确切数量.但是,有一种方法可以使用客户端列表来评估仍在输入缓冲区中处理的数据量.命令.它对应于qbuf统计信息.

There is no way to evaluate the exact number of pending commands. However, there is a way to evaluate the amount of data still to be processed in the input buffer by using the CLIENT LIST command. It corresponds to the qbuf statistic.

您还可以评估套接字缓冲区中仍要处理的数据量(Redis尚未读取的数据).在Linux上,您可以使用/proc/net/tcp中的统计信息.这是使用此策略的Python脚本的示例.

You can also evaluate the amount of data still to be processed in the socket buffers (data not read yet by Redis). On Linux, you can use statistics found in /proc/net/tcp for this. Here is an example of a Python script using this strategy.

https://gist.github.com/dspezia/2344181

您可能必须使脚本适应您的系统.

You may have to adapt the script to your system.

这篇关于Redis命令队列大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆