-
This repository uses Python 3.10
-
Create a virtual environment and install requirements to try locally
$ pyenv virtualenv 3.10.2 queues $ pyenv activate queues $ pip install -r requirements.txt
-
Install Redis
$ brew install redis
-
Start the Flask server to start serving requests
$ python ./app.py
-
In another terminal window, start Redis as your Celery broker (your task queue)
$ redis-server
-
In another terminal window, start your first Celery worker to execute tasks from the first queue
$ celery -A celery_app worker --concurrency 6 -Q slow_tasks --log-level=INFO
-
In another terminal window, start your second Celery worker to execute tasks from the second queue
$ celery -A celery_app worker --concurrency 6 -Q quick_tasks --log-level=INFO
-
In another terminal window, call the script to execute requests to the server
$ python ./server_calls.py
-
You will see the output for the following simulations:
- Calling the endpoints without queues
- Calling the endpoints using a single queue
- Calling the endpoints using multiple queues
-
While the script runs, you can monitor the Celery worker terminal windows to see how tasks are received and executed