Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the benefit of installing gunicorn for my django app on heroku?

I have recently switched to Django for a web app I'm developing and I followed the instructions at Heroku for getting a Django app running on Heroku. I have a virtual environment in which my app is developed and I use git for version control and to push to Heroku. The link above suggests that I intall gunicorn:

The examples above used the default HTTP server for Django. For production apps, you may wish to use a more production-ready embedded webserver, such as Tornado, gevent’s WSGI server, or Gunicorn.

They then walk the user through installing Gunicorn.

My question is: what problems might I run into if I skip this step and just stay with the default? What benefits will Gunicorn give me?

like image 781
Deonomo Avatar asked Jan 10 '12 17:01

Deonomo


People also ask

Why does Django need Gunicorn?

Gunicorn takes care of everything which happens in-between the web server and your web application. This way, when coding up your a Django application you don't need to find your own solutions for: communicating with multiple web servers. reacting to lots of web requests at once and distributing the load.

Do you need Gunicorn for Heroku?

Heroku is an excellent Platform As A Service (PAAS) provider that will host any Python HTTP application, and recommends using Gunicorn to power your apps. Unfortunately, the process model of Gunicorn makes it unsuitable for running production Python sites on Heroku.

Why should we use Gunicorn?

Gunicorn is a pure-Python HTTP server for WSGI applications. It allows you to run any Python application concurrently by running multiple Python processes within a single dyno. It provides a perfect balance of performance, flexibility, and configuration simplicity.

Does Heroku use Gunicorn?

Notably, Heroku provides native support for Gunicorn, which makes things easy. It's all outlined in the guides, but just to clarify, all you need to do is add a single line of code to your dash app ('server = app. server'), add Gunicorn into your requirements.


2 Answers

django's server, is a development server . It is light weigh and easy to use but should not be used in production because it is not production ready. it cannot handle many requests. This link offers a comparison between gunicorn, uwsgi and django's development server.

like image 138
razieh babaee Avatar answered Nov 07 '22 04:11

razieh babaee


Gunicorn is production ready and really easy to use. I use it for my websites. You usually should run it via a reverse proxy like Nginx. I'm not sure what Heroku is using. You really should try it.

In my experience it's much easier to use and configure than apache & mod_wsgi, and the other similar setups.

edit/update: As a summary of the comments below, Heroku already uses Nginx as a reverse proxy

like image 31
j_syk Avatar answered Nov 07 '22 03:11

j_syk