IFRCGo / go-api

MIT License
14 stars 6 forks source link

Setup async job handling using Celery #819

Open batpad opened 4 years ago

batpad commented 4 years ago

Celery is the recommended and supported way to do asynchronous job processing as well as regularly occurring "jobs" on the backend. So far, we have used regular Linux cron-jobs to handle running commands at some periodicity to handle recurring daily / hourly jobs.

This has a number of issues:

Celery provides a fairly easy to use framework to setup async tasks and periodic jobs. It will allow us to significantly better manage work queues, separate worker processes to a separate machine, and streamline logging, error handling and retry logic across tasks.

This is required for the Translation implementation as the async translation workflow cannot be run with the current Cronjobs since it needs to respond to user action. When we implement this for Translation, it will be fairly trivial to move the current cron-jobs over, and will allow us to manage all async tasks in a cohesive way, and set us up much better to be able to scale and manage tasks in the future.

A rough plan here:

Once we have the above done and working, we can create a separate ticket to move the existing cron-jobs to the new Celery setup, which should hopefully be a fairly straightforward lift.

@thenav56 please let me know if this seems like an accurate description of the plan based on our discussion, and apologies for the delay in getting this ticket up.

thenav56 commented 1 year ago

Update: The celery setup part is done through https://github.com/IFRCGo/go-api/pull/1359. And we can create a separate instance for celery on container infrastructure deployment.