如何使用类似于beantalkd的cli将Redis作为队列引擎进行监视? [英] How to monitor Redis as a queue engine using cli similar to beanstalkd?

查看:151
本文介绍了如何使用类似于beantalkd的cli将Redis作为队列引擎进行监视?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我们在 Laravel队列 .com/kr/beanstalkd"rel =" nofollow noreferrer> beanstalkd 在两个ec2实例上(在负载均衡器后面).随着系统的扩展,我们决定使用redis而不是beantalkd,并将其托管在一个AWS弹性缓存实例(具有一个主节点和两个副本的集群)上.

对于beanstalkd,我使用了 beanstalk实用程序来监视队列的运行状况;例如,如果队列被阻塞了,我可以通过运行以下命令轻松地看到这一点:

./beanstalk-queue-stats.rb localhost:11300

哪个会返回这样的内容

2018-01-10 11:08:38 +0000
default
 - cmd-delete = 32678 (+32678)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 5 (+5)
 - current-waiting = 0 (0)
 - current-watching = 2 (+2)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 32678 (+32678)
high
 - cmd-delete = 116005 (+116005)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 9 (+9)
 - current-jobs-ready = 1117 (+1117)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (+1)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 117131 (+117131)
low
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (+1)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)
marketing
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (+1)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)
------------------
2018-01-10 11:08:48 +0000
default
 - cmd-delete = 32678 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 5 (0)
 - current-waiting = 0 (0)
 - current-watching = 2 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 32678 (0)
high
 - cmd-delete = 116005 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 9 (0)
 - current-jobs-ready = 1117 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 117131 (0)
low
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)
marketing
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)

问题

我想在Redis上做同样的事情;我可以远程登录Redis并输入keys *,这将给我排队:

keys *
*4
$19
queues:high:delayed
$11
queues:high
$3
ctr
$10
queues:low

(注意它如何很好地映射到上面的beantalkd输出上的队列).但是,如果我想窥视特定的队列,然后输入以下内容,这就是我的运气结束的地方:

dump queues:high    

我变得胡言乱语

$4071
�FC^��4
       A�{"job":"Illuminate\\Queu Call`
    dHandler@c ","data":{"comm Name AApp\\Jobs\\Slack
 +�# O:17:\�
            &   \":7:{s:10 \u0 *�   message\"; `:lemon: Order *629* (code:
                                                                               1479-45157*) has been p �ed by *client Testing*. Deliv H@R
                                                                                                                                         2018-01-05 14 n:32�x3��    op_city_id  ihigh`�9�%suffix !N `�  connection�5 3qam@�4
@@6 ���`}"},"iAayA6noA7Dc9wtujE9XJ3CDqiqah5HNdby!�attempts":1}��"b�LRetai"2Newa�Push�   32 ��7�5!�5b1 .�oB��"
                                                                                                             !h�'�8��h0CEQenh9QNSqv9lhFa4LQQ6xcktrAlpY�hi!hC�LhAXNotificaBXs�   e2B��e�
  2!b8Ab8�ausers"gO:4B��&Contract#�D$bas$4M#�lId#e �er W2@W@;clas@J�e`�U ] \s $\"�
a:1:{i:0cV2;}}s$�D`*3@Z@��
1:52:20.053320`X`K@Yzone_typ@:i:3 >@��`+@vUTC �i@' {@' �Bh�2
is_unregistereA*b!% )@��)DB_prior$� Ob:1@'E\�V�Q06QFyrdyNaG2S7T2OMmpoSIjGBjZ9m0�#�AGF�1b!�(3B-�h2:03"{.600349"�"�B�����sg31WFi5ZxAYyBWM2oRvLaXfSiQwhCYK�C�"/E
�29�/E�k8 �.586574`���K65twHypvaVJfpXaZiKQx4rSD9L5EUqq�f-��Z2 c�jF24.9-T28`���oArS0cNElFDTacbOstCp32Iq4dwkbXpa�
                                                                                                               B���/,2�]6+�1 5 2 3�Ul�Kk,��"�L�lQ_broke,) F��l� j#J,���HClwcMykz2ZFiM�;��LM�[SKJh0bstcXHmRwnEBph55IzX39kxK1Lbv��"A��L�L�s:warn4���32* i4�dV.dWg����7"nP��#�h�YTtg6bBN0vcU6MDzdskeShyqYRnz4jit�����%�0��q�48.6797�����WfmvHIi0AkK8tfxZscweXGuyhQniuKGC�}Fc^��� +KEkFSe4E3kmnUu4mWpsXCpxapdkt2DSd��G����hqcbX8wls5ErNwYwyxZed9p2NIGsYID5�
      A�{"job":"Illuminate\\Queu Call`
    dHandler@c ","data":{"comm Name AApp\\Jobs\\Slack
 +�# O:17:\�
high`ge\";s:32 :warning: Order *632* is broken.`)13 )�@�G   op_city_id  i:7 N9�#suffix N `� connection�5 3qa@�4
@@6 ��!f`}"},"iAgGvVjmnQ3Ps7IYrnF83tUzDmkXKLcUfr!=attempts":1}��C�L�
                                                                    PushNotifica@�s�    �2A0���
                                                                                               2!�8A�8��users �O:4A(�lContract"6D"Wbas"zMo!KIden@�er W2@W@;clas@J�e`�U ] \s $\!Z
a:1:{i:0!�291;}}s"a��B�`*3@Z@�oBR�#"X Q@qa"�t )"ANew `)  received!`BtimB�B�Carb";#H`"�i@' {@' �B'

考虑到 dump命令的意义,它只是将值序列化为"Redis特定格式" ".

我做了什么

GUI工具❌

一个选择只是使用 gui工具查看Redis,但是由于我的Redis坐在VPC后面,那将是一种痛苦,不适合无论如何都可以制作产品(请参见相同的链接,但有限制).

CLI工具❌

此工具依赖于rdb文件格式,更多有关查看整个Redis的内容(我认为这更多是关于长期使用Redis 存储而不是仅仅一些队列,所以我没有找到合适的对象.

有人可以告诉我该怎么做吗?

解决方案

解决方法是使用此命令在本地计算机上简单地打开ssh隧道

ssh -N -L 1234:amazon.elastic.cache.redis.instance:6379 forge@ip.of.remote.server -i /Users/Shared/.ssh/secret_file.pub

查看此命令的更多详细信息 https://github.com/luin/medis

其余的工作就像一种魅力:

Background

We used Laravel Queues on top of beanstalkd on two ec2 instances (behind a load balancer). As the system scaled we decided to use redis instead of beanstalkd, and host it on an AWS elastic cache instance (with a cluster of a master node and two replicas).

With beanstalkd, I used beanstalk utilities to monitor the health of the queue; for example if the queue was getting clogged, I could easily see that by running a command like this:

./beanstalk-queue-stats.rb localhost:11300

Which would return something like this

2018-01-10 11:08:38 +0000
default
 - cmd-delete = 32678 (+32678)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 5 (+5)
 - current-waiting = 0 (0)
 - current-watching = 2 (+2)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 32678 (+32678)
high
 - cmd-delete = 116005 (+116005)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 9 (+9)
 - current-jobs-ready = 1117 (+1117)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (+1)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 117131 (+117131)
low
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (+1)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)
marketing
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (+1)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)
------------------
2018-01-10 11:08:48 +0000
default
 - cmd-delete = 32678 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 5 (0)
 - current-waiting = 0 (0)
 - current-watching = 2 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 32678 (0)
high
 - cmd-delete = 116005 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 9 (0)
 - current-jobs-ready = 1117 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 117131 (0)
low
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)
marketing
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)

Question

I would like to do the same on Redis; I can telnet into Redis and type keys *, which would give me the queues:

keys *
*4
$19
queues:high:delayed
$11
queues:high
$3
ctr
$10
queues:low

(notice how it maps nicely to the queues on the beanstalkd output above). However this is where my luck ends, if I want to peek into a specific queue, and type this:

dump queues:high    

I get gibberish:

$4071
�FC^��4
       A�{"job":"Illuminate\\Queu Call`
    dHandler@c ","data":{"comm Name AApp\\Jobs\\Slack
 +�# O:17:\�
            &   \":7:{s:10 \u0 *�   message\"; `:lemon: Order *629* (code:
                                                                               1479-45157*) has been p �ed by *client Testing*. Deliv H@R
                                                                                                                                         2018-01-05 14 n:32�x3��    op_city_id  ihigh`�9�%suffix !N `�  connection�5 3qam@�4
@@6 ���`}"},"iAayA6noA7Dc9wtujE9XJ3CDqiqah5HNdby!�attempts":1}��"b�LRetai"2Newa�Push�   32 ��7�5!�5b1 .�oB��"
                                                                                                             !h�'�8��h0CEQenh9QNSqv9lhFa4LQQ6xcktrAlpY�hi!hC�LhAXNotificaBXs�   e2B��e�
  2!b8Ab8�ausers"gO:4B��&Contract#�D$bas$4M#�lId#e �er W2@W@;clas@J�e`�U ] \s $\"�
a:1:{i:0cV2;}}s$�D`*3@Z@��
1:52:20.053320`X`K@Yzone_typ@:i:3 >@��`+@vUTC �i@' {@' �Bh�2
is_unregistereA*b!% )@��)DB_prior$� Ob:1@'E\�V�Q06QFyrdyNaG2S7T2OMmpoSIjGBjZ9m0�#�AGF�1b!�(3B-�h2:03"{.600349"�"�B�����sg31WFi5ZxAYyBWM2oRvLaXfSiQwhCYK�C�"/E
�29�/E�k8 �.586574`���K65twHypvaVJfpXaZiKQx4rSD9L5EUqq�f-��Z2 c�jF24.9-T28`���oArS0cNElFDTacbOstCp32Iq4dwkbXpa�
                                                                                                               B���/,2�]6+�1 5 2 3�Ul�Kk,��"�L�lQ_broke,) F��l� j#J,���HClwcMykz2ZFiM�;��LM�[SKJh0bstcXHmRwnEBph55IzX39kxK1Lbv��"A��L�L�s:warn4���32* i4�dV.dWg����7"nP��#�h�YTtg6bBN0vcU6MDzdskeShyqYRnz4jit�����%�0��q�48.6797�����WfmvHIi0AkK8tfxZscweXGuyhQniuKGC�}Fc^��� +KEkFSe4E3kmnUu4mWpsXCpxapdkt2DSd��G����hqcbX8wls5ErNwYwyxZed9p2NIGsYID5�
      A�{"job":"Illuminate\\Queu Call`
    dHandler@c ","data":{"comm Name AApp\\Jobs\\Slack
 +�# O:17:\�
high`ge\";s:32 :warning: Order *632* is broken.`)13 )�@�G   op_city_id  i:7 N9�#suffix N `� connection�5 3qa@�4
@@6 ��!f`}"},"iAgGvVjmnQ3Ps7IYrnF83tUzDmkXKLcUfr!=attempts":1}��C�L�
                                                                    PushNotifica@�s�    �2A0���
                                                                                               2!�8A�8��users �O:4A(�lContract"6D"Wbas"zMo!KIden@�er W2@W@;clas@J�e`�U ] \s $\!Z
a:1:{i:0!�291;}}s"a��B�`*3@Z@�oBR�#"X Q@qa"�t )"ANew `)  received!`BtimB�B�Carb";#H`"�i@' {@' �B'

Which makes sense, considering that the dump command simply serializes the value in a "Redis specific format".

What I have done

GUI tools ❌

One option was simply looking at Redis using a gui tool but since my Redis is sitting behind a VPC, setting that up would be a pain and not suitable for prod anyway (see same link under limitations).

CLI tools ❌

This tool relies on the rdb file format, which is more about looking at the content of your entire Redis (I feel it's more about using Redis as a long term storage rather than just some queue, so I didn't see the fit).

Can someone tell me how to do this?

解决方案

the fix is to simply open an ssh tunnel on my local machine using this command

ssh -N -L 1234:amazon.elastic.cache.redis.instance:6379 forge@ip.of.remote.server -i /Users/Shared/.ssh/secret_file.pub

see more details of this command here

then i installed this open source redis gui tool: https://github.com/luin/medis

the rest worked like a charm:

这篇关于如何使用类似于beantalkd的cli将Redis作为队列引擎进行监视?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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