How to run gevent in production

Flavien picture Flavien · Jun 13, 2012 · Viewed 19.2k times · Source

I am making use of gevent in my Python application (Django based). However, I am now wondering how to run it in production. What server should I use? During development, I use gevent.pywsgi, but is that production-ready? I have also heard about gunicorn, but I've seen some pretty bad benchmarks about it.

Note: I need SSL.

Answer

rdegges picture rdegges · Aug 1, 2012

Gunicorn is really the best option. It's fast, it's written in pure python (which makes it easy to deploy on hosted services like Heroku), and it's well maintained and used for a large amount of Python web applications.

By default, Gunicorn uses a synchronous worker class to serve requests, but it can be easily configured to use gevent by simply adding -k gevent to the run command.

Just a quick note: you should always run gunicorn behind a proxy like NGINX, Varnish, etc., as this will allow gunicorn to handle far more requests than it can otherwise, due to response buffering.