4

I am a newbie to python world and somewhere I read that using uWSGI behind nginx is much better, because that frees up nginx to simply serve content, and lets you choose how many tiny light nginx threads to run, independently of your choice of how many heavyweight Python threads you bring up to serve dynamic content.

So, I searched on google about what is nginx and I got a result: enter image description here

From the image above I understood that nginx is a web server.

Then I searched for uWSGI and I opened the first result which says:enter image description here

As you can see in above image, uWSGI is capable of serving the web applications.

So, I think that if uWSGI and Nginx are both web servers then why should I use them together. That doesn't make sense to me. Can somebody explain me about that?

Vishal
  • 6,238
  • 10
  • 82
  • 158

1 Answers1

3

You can run just a uwsgi server by itself (with the http option) to serve your application without running an nginx server. Whether that makes sense will depend on your service needs.

Generally: if you have a lot of static content (web pages, css/js files, images, etc.), running nginx to serve those while proxying other requests to uwscgi may be the most efficient way to do things.

If you serve only dynamic content (i.e stuff that must go through Python), then a uwsgi server alone should do fine.

If you know what your load will be like, then best way to determine which setup is appropriate is create and run a simulation (i.e. use wrk or ab and have them hit the various static/non-static pages). Run the simulation with both of the above configurations and see which gives you the performance envelope that works best for you.

Allen Luce
  • 7,859
  • 3
  • 40
  • 53