Gunicorn/uwsgi vs build in http server


#1

What benefits I will get if from using gunicorn/uwsgi instead of build-in Sanic http server?

The same question about using nginx instead of build in static file serving.


#2

I think the biggest benefit of gunicorn would be familiarity. If you are coming from another framework and know how to manipulate it to your needs, then it would be a comfort thing. There are some settings that you might want that are not enabled in Sanic.

For example, the docs talk about serving a max number of requests before a worker is killed off and a new one started up. This is not something that Sanic does out of the box, so if it is something you need, then perhaps gunicorn would be an easier solution than trying to implement it yourself (which you entirely could do).

Honestly, (and I am a little biased) I see no personal gain from using gunicorn.

As for static files, nginx is far better at serving static files than Python, which is far better at serving dynamic content. You can use it to compress the files, cache them, and overall do a much more efficient and faster delivery of that static content. Nginx is very fast at what it does, so it generally makes sense to offload as much work as you can to it and keep your Python workers to processing the dynamic content.

Does this help?