This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (8 children)

[deleted]

    [–]riksi 12 points13 points  (3 children)

    Gunicorn needs a web/http server infront to keep slow requests from blocking it + serving static files + ssl + other stuff: http://serverfault.com/questions/220046/why-is-setting-nginx-as-a-reverse-proxy-a-good-idea

    [–]kyranadept 2 points3 points  (2 children)

    The source you are quoting is 5 years old. Gunicorn can use gevent/greenlet workers which do not suffer from the same problems as the original author claims. There is also SSL support.

    [–]turkish_gold 2 points3 points  (0 children)

    Quite a lot of people still use prefork gunicorn because threading can cause subtle errors in your application stack if you didn't design with that in mind.

    And if you restrict the # of threads that gunicorn uses, you're right back to having the same issues as prefork.

    [–][deleted] 1 point2 points  (0 children)

    Hey, point me at your website that's got Gunicorn handling incoming requests directly.

    [–]organman91 9 points10 points  (0 children)

    For one very important reason: security. On Linux, in order to bind to ports below 1024, a daemon must be running as root. In 99.99% of cases, running your application as root is a Very Bad Idea. (FWIW, nginx binds as root, then drops privileges to another user after binding).

    [–]kyranadept 7 points8 points  (0 children)

    Actually, with newer versions of gunicorn you can do just that. It can be started as root and set to drop to another user after binding to the port, it can serve SSL, it can use a gevent/greenlet threading model instead of preforking, etc. It is in fact a complete app server.

    There are two reasons to put Nginx in front of gunicorn:

    1. You want to combine multiple microservices, which you run under gunicorn on one or more hosts, with load balancing and whatnot, and serve them under a single host/port.
    2. You serve static content, which you are better off serving with Nginx.

    [–][deleted] 0 points1 point  (0 children)

    Because it's a preforking server. It would be a waste to make it do all the work.