How to run gevent in production

22,985

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.

Share:
22,985

Related videos on Youtube

Flavien
Author by

Flavien

Updated on August 01, 2020

Comments

  • Flavien
    Flavien almost 4 years

    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.

    • Mark Lavin
      Mark Lavin about 12 years
      Two points about this benchmark. 1.) The gunicorn test uses the default sync worker not the gevent worker that you are looking to use. 2.) From the summary "If there is one thing which made this benchmark clear is that most Python Web servers offer great performance and if you feel things are slow the first thing to look at is really your own application."
    • akent
      akent about 12 years
      See answer to a similar question (stackoverflow.com/questions/7855343/run-web-app-with-gevent‌​/…), the author of gevent himself says, in a nutshell, "Use gunicorn."
  • Flavien
    Flavien almost 12 years
    I've seen that I need to disable buffering if I use it with gevent. Does it cancel the benefits of Nginx?
  • Alex K
    Alex K over 11 years
    What is the point of using HTTP on back-end server? Unlike FastCGI, SCGI and uwsgi, HTTP wasn't designed for front-end to back-end communication and using it for that purpose has its limitations and problems.
  • dhackner
    dhackner over 11 years
    I believe you don't need to worry about running with a reverse proxy like nginx when using Heroku since the routing mesh handles it.
  • twneale
    twneale about 10 years
    @Flavien only if you're doing streaming stuff, like long polling, comet, etc.
  • hafiz031
    hafiz031 over 2 years
    Hi, what is the difference between the flags: k and worker-class? docs.gunicorn.org/en/stable/…
  • shaye059
    shaye059 over 2 years
    @hafiz031 There's no difference, one is a short version and the other is the long version of the option so you can use either one (superuser.com/questions/174564/…)