Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is gevent + gunicorn scalable and stable for production use?

I have been looking at python web servers which offer scalability and decided to go with either Tornado (used by Facebook FriendFeed) or Gevent. Since I am pretty new to this, I relied on the Benchmark of Python Web Servers to shortlist Tornado and Gevent. Moreover, after further research I found out that:

  • Gevent is not an independent web server, we need to use either libevent or gunicorn as a web server.
  • libevent has its pitfalls, such as not supporting SSL, streaming, keep alive and websockets.
  • There is no benchmarking result available which I could find which documents the performace of gevent and gunicorn used together.
  • The author of gevent himself has recommended everyone to use gevent + gunicorn for actual deployment.

My requirements:

  • A highly scalable asynchronous python web server.
  • SSL Support included.

I am particularly more inclined towards gevent because of its greenlet based approach. I just want some hard facts to prove that gunicorn + gevent is a good choice and is highly scalable, in league with Tornado. Or is there any other python web server which meets my requirements?

Do point me in the right direction.

like image 793
sultan.of.swing Avatar asked Dec 13 '12 04:12

sultan.of.swing


People also ask

Is Gunicorn scalable?

Gunicorn allows us to run multiple worker processes of a single app. It's really simple, and we can easily scale up or down our number of workers. For example, the following code runs 2 workers of myapp.

Does Gunicorn use gevent?

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 Gunicorn works?

Gunicorn is based on a pre-fork worker model, compared to a worker model architecture. The pre-work worker model means that a master thread spins up workers to handle requests but otherwise does not control how those workers perform the request handling. Each worker is independent of the controller.

What is gevent flask?

gevent allows writing asynchronous, coroutine-based code that looks like standard synchronous Python. It uses greenlet to enable task switching without writing async/await or using asyncio . eventlet is another library that does the same thing.


1 Answers

As of this writing, Gunicorn is in beta (version 0.16) and Gevent has a release candidate for 1.0 (Announcement on Google Groups), so it might be reasonable to expect changes in the API (less so for Gevent) That said, as long as you track the mailing lists (here: gunicorn, gevent) for changes that could break your application, you should be fine with a production deployment

Gunicorn+Gevent is a good choice for an asynchronous python web server. You should perform your own tests to compare it with Tornado. Publicly available benchmarking tests might be misleading since your application may not behave as those subjected to benchmarking.

For SSL support, both Gunicorn and Tornado recommend you run them behind a reverse proxy such as nginx. Additional advantages of running them behind a reverse proxy include improved handling of slow clients and bad HTTP requests

like image 134
Elvis D'Souza Avatar answered Sep 22 '22 20:09

Elvis D'Souza