Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery Tasks with eta get removed from RabbitMQ

I'm using Django 1.6, RabbitMQ 3.5.6, celery 3.1.19.

There is a periodic task which runs every 30 seconds and creates 200 tasks with given eta parameter. After I run the celery worker, slowly the queue gets created in RabbitMQ and I see around 1200 scheduled tasks waiting to be fired. Then, I restart the celery worker and all of the waiting 1200 scheduled tasks get removed from RabbitMQ.

How I create tasks: my_task.apply_async((arg1, arg2), eta=my_object.time_in_future)

I run the worker like this: python manage.py celery worker -Q my_tasks_1 -A my_app -l

CELERY_ACKS_LATE is set to True in Django settings. I couldn't find any possible reason.

Should I run the worker with a different configuration/flag/parameter? Any idea?

like image 792
Emin Bugra Saral Avatar asked Dec 28 '15 14:12

Emin Bugra Saral


People also ask

What happens when a Celery task fails?

Celery will stop retrying after 7 failed attempts and raise an exception.

Why you should use Celery with RabbitMQ?

It's incredibly lightweight, supports multiple brokers (RabbitMQ, Redis, and Amazon SQS), and also integrates with many web frameworks, e.g. Django, etc. Celery's asynchronous task queue allows the execution of tasks and its concurrency makes it useful in several production systems.

What is ETA in Celery?

The ETA (estimated time of arrival) lets you set a specific date and time that is the earliest time at which your task will be executed. countdown is a shortcut to set eta by seconds into the future. >>> result = add. apply_async(args=[10, 10], countdown=3) >>> result. get() # this takes at least 3 seconds to return 20.

Where are Celery tasks stored?

But, Celery doesn't actually store the queue of tasks in its memory. It needs somebody else to store the tasks, it needs a Message Broker (or Broker for short), which is a fancy term for a program that can store and handle a queue 🙃. These are usually either Redis or RabbitMQ.


1 Answers

As far as I know Celery does not rely on RabbitMQ's scheduled queues. It implements ETA/Countdown internally.
It seems that you have enough workers that are able to fetch enough messages and schedule them internally.
Mind that you don't need 200 workers. You have the prefetch multiplier set to the default value so you need less.

like image 69
the_drow Avatar answered Oct 11 '22 03:10

the_drow