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:
My requirements:
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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With