Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache + mod_wsgi vs nginx + gunicorn

I want to deploy a django site (it is the open source edx code on github).

I am faced with choosing between using

  1. Apache with mod_wsgi
  2. nginx with gunicorn

I have used Apache with mod_wsgi and it's cool enough, but i have no experience with the second option.

Which of these would be a better option in terms of speed and also to some extent, ease of use?

NB: I would need to run two different django sites on say, port 80 and 81 and access them from two different subdomains.

like image 523
SamAko Avatar asked Aug 04 '13 22:08

SamAko


People also ask

Should I use nginx Gunicorn?

Although there are many HTTP proxies available, we strongly advise that you use Nginx. If you choose another proxy server you need to make sure that it buffers slow clients when you use default Gunicorn workers. Without this buffering Gunicorn will be easily susceptible to denial-of-service attacks.

Is Gunicorn similar to Apache?

The Apache HTTP Server is a powerful and flexible HTTP/1.1 compliant web server. Originally designed as a replacement for the NCSA HTTP Server, it has grown to be the most popular web server on the Internet. On the other hand, Gunicorn is detailed as "A Python WSGI HTTP Server for UNIX".

Which is better Nginx or Apache?

In terms of performance, NGINX is much better than Apache. NGINX performs 2.5 times faster than Apache — and consumes less memory as well. However, Apache has more functionality and features. It is worth noting that it is possible to use both together.

Should I use Gunicorn or uWSGI?

Short answer: Use Gunicorn, unless you are deploying on Windows, in which case use mod_wsgi. So, from the operating system's point of view, your Django project becomes a part of the WSGI server; it is the same process.


1 Answers

Nginx is a really light and easy to use solution and along with gunicorn it allows us to run any wsgi application and scale it easily. Nginx is better at handling requests since it does not spawn a new process for every request unlike Apache.

I have written an answer on how to deploy django with nginx for a related question:

Deploying Django project with Gunicorn and nginx

like image 72
Pranjal Mittal Avatar answered Oct 07 '22 07:10

Pranjal Mittal