Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a real queue worker #4680

Closed
zuhdil opened this issue Oct 28, 2021 · 2 comments
Closed

Use a real queue worker #4680

zuhdil opened this issue Oct 28, 2021 · 2 comments

Comments

@zuhdil
Copy link
Contributor

zuhdil commented Oct 28, 2021

Currently, RSR uses cronjobs to handle one-time background tasks. Using a proper queue worker opens up the possibility to defer tasks to the queue such as sending email and processing data that was previously done in the request handler.

@zuhdil zuhdil self-assigned this Oct 28, 2021
@MichaelAkvo
Copy link
Contributor

MichaelAkvo commented Aug 17, 2022

There are multiple available choices. The most known one is probably Celery and maybe Apache Kafka.

Name active Task search/listing django ORM broker python package Ease of use setup costs
celery yes no maybe yes medium medium
django-q no no yes yes easy low
dramatiq yes no yes medium
kafka yes no no difficult high
python-rq yes no yes easy medium

With all things considered, I think going with celery is the best.

@MichaelAkvo MichaelAkvo assigned MichaelAkvo and unassigned zuhdil Sep 19, 2022
@MichaelAkvo MichaelAkvo added this to RSR Dec 7, 2022
@MichaelAkvo MichaelAkvo moved this to Todo in RSR Dec 7, 2022
@MichaelAkvo MichaelAkvo moved this from Todo to In Progress in RSR Jan 30, 2023
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
This follows https://docs.celeryq.dev/en/stable/django/first-steps-with-django.html
 to add celery as a dependency and queue worker.
A worker still has to be called in docker-compose and added to kubernetes
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
[#4680] Start adding celery as a queue worker
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
[#4680] Start adding celery as a queue worker
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
The worker should only start once the web service is healthy
 and has run all migrations

[#4680] Start adding celery as a queue worker
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
celery does require a broker.
We aren't doing a lot of things that require many async actions
 nor do we need a super fast broker.
Moving tasks to their own files will be enough to allow
 an easier migration to celery at some point in the future.

[#4680] Use a real queue worker
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
[#4680] Use a real queue worker
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
The command is of course in the container

[#4680] Use a real queue worker
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
It was also necessary to add a healthcheck for the service

[#4680] Use a real queue worker
@MichaelAkvo
Copy link
Contributor

MichaelAkvo commented Feb 1, 2023

Celery requires rabbitMQ or some other message queue. Seems like an unnecessary hassle for what we want to do (run a few jobs async). It's not like we're some high throughput application. Should we require high performance, multiple workers, and 5 9s for async tasks, we can talk about rabbitmq, kafka, etc.

Going with django-q which simply allows using postgres for queuing tasks.

MichaelAkvo added a commit that referenced this issue Feb 1, 2023
celery does require a broker.
We aren't doing a lot of things that require many async actions
 nor do we need a super fast broker.
Moving tasks to their own files will be enough to allow
 an easier migration to celery at some point in the future.

[#4680] Use a real queue worker
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
[#4680] Use a real queue worker
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
The command is of course in the container

[#4680] Use a real queue worker
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
MichaelAkvo added a commit that referenced this issue Feb 1, 2023
It was also necessary to add a healthcheck for the service

[#4680] Use a real queue worker
@MichaelAkvo MichaelAkvo added this to the New task management milestone Feb 8, 2023
MichaelAkvo added a commit that referenced this issue Feb 8, 2023
It was also necessary to add a healthcheck for the service

[#4680] Use a real queue worker
@MichaelAkvo MichaelAkvo moved this from In Progress to In Review in RSR Feb 13, 2023
MichaelAkvo added a commit that referenced this issue Feb 23, 2023
When loading the task dictionary, it looks like the referenced function is also dereferenced into a function object.

Co-authored-by: zuhdil <zuhdil@gmail.com>
MichaelAkvo added a commit that referenced this issue Feb 23, 2023
When loading the task dictionary, it looks like the referenced function is also dereferenced into a function object.

Co-authored-by: zuhdil <zuhdil@gmail.com>
zuhdil added a commit that referenced this issue Feb 28, 2023
MichaelAkvo added a commit that referenced this issue Feb 28, 2023
There's no need to do other stuff as the backend container should be in charge of that

[#4680] Use a real queue worker
MichaelAkvo added a commit that referenced this issue Feb 28, 2023
It expects a list or args, not a string as it makes arg parsing more difficult

[#4680] Use a real queue worker
@github-project-automation github-project-automation bot moved this from In Review to Done in RSR Feb 28, 2023
MichaelAkvo added a commit that referenced this issue Feb 28, 2023
The probe takes more than 1 second to execute and the default timeout for the execution is 1 second.

[#4680] Use a real queue worker
MichaelAkvo added a commit that referenced this issue Feb 28, 2023
[#4680] fix: timings for worker container readiness and liveliness probe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants