Minimal example utilizing fastapi and celery with RabbitMQ for task queue, Redis for celery backend and flower for monitoring the celery tasks.
- Python >= 3.6.x
- pipenv (
pip install pipenv
)
- pipenv (
- Docker
- docker-compose
Execute the following command:
pipenv --python <your_python_version>
pipenv install --dev
- Run command
docker-compose up
to start up the RabbitMQ, Redis and flower instances. - Start the fastapi web application with
pipenv run uvicorn main:app --reload
. - Start the celery worker with command
pipenv run celery worker -A worker.celery_worker -l info -Q test-queue -c 1
Navigate to the http://localhost:8000/docs and execute test API call. You can monitor the execution of the celery tasks in the console logs or navigate to the flower monitoring app at http://localhost:5555 (username: user, password: test).