Gearman框架的管理

1.查看队列中的job数量

(echo status; sleep 0.1) | nc 127.0.0.1 4730

命令的结果会分为四列,它们的含义从左到右依次是:

  1. Function name: A string denoting the name of the function of the job
  2. Number in queue: A positive integer indicating the total number of jobs for this function in the queue. This includes currently running ones as well (next column)
  3. Number of jobs running: A positive integer showing how many jobs of this function are currently running
  4. Number of capable workers: A positive integer denoting the maximum possible count of workers that could be doing this job. Though they may not all be working on it due to other tasks holding them busy.

从这些信息可以推断出:如果系统比较繁忙的话,Number of jobs running的数值会接近Number of capable workers;Number in queue可能会大于Number of capable workers。此时我们应该增加Worker的数量,反之则应该考虑减少Worker的数量。

2.推荐大家结合使用watch命令来监控Gearman的状态,这样更直观一些:

shell> watch -n 1 "(echo status; sleep 0.1) | nc 127.0.0.1 4730"

实际应用中,还有很多特殊情况需要考虑,比如说:程序代码更新后,如何避免手动重启Worker?还需要注意的是Worker长时间运行,一旦意外中断或者内存泄漏怎么办?通常这类进程控制问题用Supervisor都可以轻松搞定,有兴趣的读者自己看看吧。此外网络上还有一些不错的工具可以玩玩,比如:GearmanManagerGearman-Monitor

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值