Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run gevent in production

Tags:

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.

like image 332
Flavien Avatar asked Jun 13 '12 14:06

Flavien


People also ask

How do you use a gevent worker?

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.

How do you use a gevent flask?

The easiest way to run a Flask application is to use a built-in development server. But even this beast supports two modes of request handling. In the single-threaded mode, a Flask application can handle no more than one HTTP request at a time. I.e. the request handling becomes sequential.

Is gevent a server?

server – TCP/SSL server. If the user initialized the server with an address rather than socket, then this function must create a socket, bind it, and put it into listening mode.

What is gevent Eventlet?

gevent is a coroutine-based cooperative multitasking python framework that relies on monkey patching to make all code cooperative. Gevent actually draws its lineage from Eve Online which was implemented using Stackless Python which eventually evolved into eventlet which inspired gevent.


1 Answers

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.

like image 75
rdegges Avatar answered Sep 27 '22 21:09

rdegges