I have a question regarding django-rq. It is pip-installed library that functions as a small layer on top of python-rq, which runs on a redis instance. Currently, I run all of the jobs on the default queue that uses database 0 on my local redis instance.
I spin up workers by running the following script x times for x workers on the default queue:
nohup ~/.virtualenvs/prod/bin/python3 manage.py rqworker default &
nohup rq resume --url="redis://localhost:6379/0"
I am operating on an 8 core / 32GB RAM machine. For every incoming request, a worker is required to process the job, which can often take anywhere from 3 to 60 minutes in a background process, that uses OpenCV, Tesseract and a few other APIs, making a few HTTP requests along the way.
How do I know the ideal number of rq workers I should be using? I am looking at the administrative panel and it says 8 workers. Is this the ideal number of workers that I should be using? Should I use 20? How about 100?
How do I account for the following variables, in order to choose the correct number of workers I should spin up:
- number of incoming requests
- amount of RAM needed per process
- number of cores
- likelihood of a worker possibly breaking down