Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are prefetched tasks in celery being acknowledged?

I have following setup:

  • RabbitMQ broker + Django
  • Celery with CELERYD_PREFETCH_MULTIPLIER=32 (I have a lot of small task thus prefetching them makes a lot of sense from performance standpoint)
  • CELERY_ACKS_LATE=False (tasks are not idempotent)

I run celery in docker container, so when I rebuild docker celery workers are not gracefully shut down. This is ok, if tasks are not acknowledged as broker will sent them back once workers be up again in new docker container, but in other case they - will be lost.

In flower admin panel prefetched tasks have status received.

I had carefully read official documentation and related question and intuitively I feel that prefetched tasks in my setup are acknowledged. Is it so?

like image 849
Dmytriy Voloshyn Avatar asked Oct 30 '22 12:10

Dmytriy Voloshyn


1 Answers

With CELERY_ACKS_LATE=False task will be acknowledged as soon as worker starts to execute it: just before execution.

So if a worker starts to execute a task and you kill it task will be lost. Other prefetched tasks won't be lost because they are still unacknowledged.

like image 150
Raz Avatar answered Nov 11 '22 15:11

Raz