1

I am trying to monitor celery queue so that if no of tasks increases in a queue i can chose to spawn more worker.

How can i do this with or without Flower(the celery monitoring tool)

eg: I can get a list of all the workers like this

curl -X GET http://localhost:5555/api/workers

{
    "celery@ip-172-0-0-1": {
        "status": true,
        "queues": [
            "tasks"
        ],
        "running_tasks": 0,
        "completed_tasks": 0,
        "concurrency": 1
    },
    "celery@ip-172-0-0-2": {
        "status": true,
        "queues": [
            "tasks"
        ],
        "running_tasks": 0,
        "completed_tasks": 5,
        "concurrency": 1
    },
    "celery@ip-172-0-0-3": {
        "status": true,
        "queues": [
            "tasks"
        ],
        "running_tasks": 0,
        "completed_tasks": 5,
        "concurrency": 1
    }
}

similarly i need a list of tasks pending by queue name so i can start a worker on that queue.

Thanks for not down voting this question.

Vikash Singh
  • 13,213
  • 8
  • 40
  • 70
  • I think Celery's autoscale option is what you're looking for: http://celery.readthedocs.org/en/latest/internals/reference/celery.worker.autoscale.html – Erve1879 Feb 02 '15 at 13:42
  • Sorry, i am not looking for AutoScale i am looking for a way to find out how many pending jobs are there in celery grouped by queue. – Vikash Singh Feb 02 '15 at 13:48
  • Try inspect().reserved(). See comment to this answer: http://stackoverflow.com/a/9369466/1213425. However, your first sentence in this questions suggests you want to manually scale your worker pool when the number of tasks goes above a certain number..... Not sure why you'd want to manually do what celery can achieve automatically......? Flower can also tell you how many tasks are in a queue..... – Erve1879 Feb 02 '15 at 14:05
  • Also, if you don't need to know what the tasks are, you could get the length of a queue from your broker and use that statistic to decide to scale up/down.... – Erve1879 Feb 02 '15 at 14:06
  • @Erve1879 Will try 'length of a queue from your broker' approach. What celery auto scaling does is it increases concurrency. But i want to scale horizontally ie. i want to spawn more boxes with same worker. – Vikash Singh Feb 02 '15 at 14:34
  • Ah, I see. EC2/SQS/CloudWatch makes that easy...... – Erve1879 Feb 02 '15 at 14:57
  • ok @Erve1879 will try to learn and use that. Thanks :) – Vikash Singh Feb 02 '15 at 15:03

1 Answers1

2

Reserved tasks does not make sense here. it only includes the portion of received but not running ones.

We could use rabbitmq-management to monitor the queue if using RabbitMQ as broker. celery document also provide some ways to do the same things.

Jacky1205
  • 3,273
  • 3
  • 22
  • 44