I have three Celery tasks:
- prediction
- training
- healthcheck
And I have 4 cpus in the machine. I would like to allocate 3 workers for prediction and training, and 1 for healthcheck. What is the easiest way to implement that? Note that I am going to schedule these tasks, and thus, I can't specify the number of workers in the apply_async() function directly.
Actual configs:
CELERY = Celery(
CELERY_APP_NAME,
backend=CELERY_BACKEND,
broker=CELERY_BROKER,
include=["src.tasks"],
)
CELERY.conf.update({"task_routes": {"src.tasks.*": {"queue": "input_queue"}},
}
)
@CELERY.task
def prediction():
pass
@CELERY.task
def training():
pass
@CELERY.task
def healthcheck():
pass
And the command to run the worker:
celery --loglevel=INFO -A src.tasks worker -Q input_queue