14

I am experimenting with various setups for deploying django apps. My first choice was using a simple apache server with mod_wsgi, which I had implemented before for private use. Since the current deployment is for public use, I am looking at various options. Based on the information available online, it seems it is good to have nginx for serving static content as well as a reverse proxy for a dynamic content server. Now given my previous knowledge of Apache I was considering using the same for dynamic content. But then I came across Gunicorn and later uWSGI. Currently I am implementing uWSGI. I see that it allows multiple protocols including http.

What are the advantages of using one protocol over the other. I understand that given my requirement of scaling the app over multiple servers, means that I cannot use Unix sockets, which seem to be recommended in some tutorials. So the other choices are TCP socket with uwsgi or with http. Do they have much theoretical difference. I am not aware of the details of uwsgi protocol and would like to know, if using it over http protocol would make things faster?

Vipul Patil
  • 468
  • 5
  • 17

1 Answers1

20

Ultimately your bottlenecks are not going to be in the particular routing mechanisms for requests unless you really muck up the configuration. So arguably a waste of time to be focused too much on basing decisions on things at that level.

Go watch my talk from PyCon for some context on where bottlenecks are really going to be.

http://lanyrd.com/2012/pycon/spcdg/

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • I have seen your talk and had a feeling that this would be your answer. But just for an academic knowledge purpose, is it faster? – Vipul Patil Aug 04 '12 at 06:58
  • 7
    The difference is that in HTTP the recipient has to parse for the request header field separator and end of line marker. In uwsgi, binary length bytes are incorporated in the data so recipient knows already what length of field is and doesn't have to parse it. So you may save a minute amount of time using uwsgi, but you really are splitting hairs. The design of the server side software is going to be much more important. Sloppy coding in the algorithm for handling it would quickly wipe out any saving. Even the uWSGI author will acknowledge that at that level the difference is very minor. – Graham Dumpleton Aug 04 '12 at 10:37
  • 4
    Link is dead, but I found the following: Talks: 1. [youtube.com - PyCon Australia 2012 - Web Server Bottlenecks And Performance Tuning](https://www.youtube.com/watch?v=eOkxLCCbU9w) 2. [youtube.com - PyCon Us 2012 - Web Server Bottlenecks And Performance Tuning](https://www.youtube.com/watch?v=Bt2HStzaBzE) Slides: [slideshare.net - PyCon Us 2012](https://www.slideshare.net/GrahamDumpleton/pycon-us-2012-web-server-bottlenecks-and-performance-tuning) – Murmel Nov 26 '18 at 15:26