Django and nginx. Do I still need Apache?

I searched in this thread and there seems to be advice that nginx should be there to serve static files and apache + wsgi to work with Django. For many, this information is a couple of years old, so I was wondering if there is a way to simplify this without sacrificing performance and just rely on Nginx and fastCGI and / or wsgi.

I'm new to deployment without a hero, so I probably sound like I don't know what I'm talking about.

+4
source share
2 answers

No, you do not need Apache + wsgi with Nginx + fCGI / wsgi. Nginx can execute static files very quickly, and it will use fCGI / wsgi for the rest of the requests.

You should read the answer to this question [1] and other related questions mentioned there.

[1]. What is the disadvantage of using Django's fastcgi server

+5
source

If you want to go along the nginx route, select the following options:

  • nginx → gunicorn
  • nginx → uWSGI

Running WSGI applications in Python on top of FASTCGI is usually not so good due to problems with the FASTCGI / WSGI adapters and how they are deployed to the servers.

Apache / mod_wsgi is still a more acceptable solution, and it will work better with less resources on startup like:

  • nginx → Apache / mod_wsgi

Since bottlenecks will not be a web server, ultimately, it doesn’t matter what you choose until you set it up correctly, what most people will not do, because the site doesn’t get anyway, or they don’t have monitoring to know what they need to change.

In general, a choice that you think is easier to manage is the best thing you can do at startup.

For some background, what will be your real performance bottlenecks and the importance of monitoring, see:

All of the above, you mention Geroku. Right now there is really only one time with Heroku, and that should use gunicorn, and you won’t have to worry about nginx. This in itself, since guns alone is not a good option for serving static media assets that are almost forced to use Heroku to serve static certificates in other places.

+3
source

Source: https://habr.com/ru/post/1447663/


All Articles