Apache + mod_wsgi vs nginx + gunicorn

前端 未结 4 1500
天涯浪人
天涯浪人 2021-01-31 17:04

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
相关标签:
4条回答
  • 2021-01-31 17:18

    I have good experience with nginx and gunicorn. They keep on working great when I've finally set all the settings right and got it running.

    For nginx and gunicorn they are:

    * nginx configuration files (/etc/nginx/sites-enabled/ and /etc/nginx/nginx.conf)
    * gunicorn configuration files (/etc/init/gunicorn.conf and /etc/gunicorn.d/) 
    

    I've seen a tutorial for apache + mod_wsgi and it seems so much simpler to set up.

    0 讨论(0)
  • 2021-01-31 17:25

    I have primarily worked with nginx and gunicorn. I am currently working with apache + mod_wsgi. It is actually easy if your Python version is 2.7 because mod_wsgi when installed directly from the package manager will work normally. But if your code is in a different Python version. mod_wsgi has to be built from source with the same version. If you installed your Python also from source then the procedure to get the whole web application working is fairly difficult.

    Nginx and gunicorn on the other hand do not have any version issues, since the proxypass param makes it easy to forward requests to gunicorn. All we need to ensure is that gunicorn is running with the same version of Python that your code is in.

    0 讨论(0)
  • 2021-01-31 17:27

    Well,the few milliseconds you get with Nginx will not make a hudge difference regarding the time other processes take. Nginx may save RAM but it would only be a great difference on servers with a few RAM. For specific uses on big website there could be some more notable differences but this will become an expert affair then.

    The real difference for most is probably the ease of learning. I don't find Apache to be specifically hard to use and the doc is clean. However most of Python tutorials I found are about using Nginx with Gunicorn.

    If you already know how to use Apache with Python it would probably be more straight to the point to use it, unless you want to learn Nginx too to improve your CV.

    However, if you are a newcomer, there is more documentation about Nginx with Python. It makes it the easier option.

    0 讨论(0)
  • 2021-01-31 17:30

    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

    0 讨论(0)
提交回复
热议问题