We need fast async support and also worker restarts after N requests, and so right now we are using Gunicorn with the Uvicorn worker according to their recommendation. When we run Uvicorn with a max request limit, the workers don’t restart and that is an issue.
On the sanic documentation, you recommend when deploying with gunicorn that we use the sanic worker sanic.worker.GunicornWorker
https://sanic.readthedocs.io/en/latest/sanic/deploying.html#running-via-gunicorn
But on the uvicorn docs, they recommend using their worker uvicorn.workers.UvicornWorker
https://www.uvicorn.org/deployment/
I know that you recommend using the sanic server directly for the best performance — but when we tested in production, it suffers from some issues, mainly that I cannot seem to restart the workers. This is an important requirement for us to deal with unexpected exceptions that appear to lead to memory leaks in some instances.
So I am wondering what config I should use that will meet my requirements:
- worker supports restarts after N requests
- most performant running async code
And also, if I use gunicorn, which worker should I in fact be using that will satisfy my requirements?