Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Celery discourage worker & beat together?

From the celery help function:

> celery worker -h

...

Embedded Beat Options:
  -B, --beat            Also run the celery beat periodic task scheduler. Please note that there must only be
                        one instance of this service. .. note:: -B is meant to be used for development
                        purposes. For production environment, you need to start celery beat separately.

This also appears in the docs.

You can also embed beat inside the worker by enabling the workers -B option, this is convenient if you’ll never run more than one worker node, but it’s not commonly used and for that reason isn’t recommended for production use:

celery -A proj worker -B

But it's not actually explained why it's "bad" to use this in production. Would love some insight.

like image 876
zerohedge Avatar asked Jul 18 '18 03:07

zerohedge


People also ask

How does celery define workers?

When you run a celery worker, it creates one parent process to manage the running tasks. This process handles the book keeping features like sending/receiving queue messages, registering tasks, killing hung tasks, tracking status, etc.

Why do celery workers go offline?

According to the documentation (docs.celeryproject.org/en/stable/userguide/…), a worker sends a heartbeat every minute. If no heartbeat has been received for 2 minutes, the worker is considered to be offline, i.e. disconnected from the broker.

What does celery do in Airflow?

Airflow Celery is a task queue that helps users scale and integrate with other languages. It comes with the tools and support you need to run such a system in production. Executors in Airflow are the mechanism by which users can run the task instances.


Video Answer


1 Answers

The --beat option will start a beat scheduler along with the worker.

But you only need one beat scheduler。

In the production environment, you usually have more than one worker running. Using --beat option will be a disaster.

For example: you have a event scheduled at 12:am each day.

If you started two beat process, the event will run twice at 12:am each day.

If you’ll never run more than one worker node, --beat option if just fine.

like image 188
gushitong Avatar answered Oct 29 '22 03:10

gushitong