Reputation: 551
I would like to know what is the difference between starting a gunicorn WSGI server with eventlet workers
gunicorn --workers=2 -k eventlet test:app
and starting a wsgi server programmatically like
from eventlet import wsgi
import eventlet
def hello_world(env, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello, World!\r\n']
wsgi.server(eventlet.listen(('', 8090)), hello_world)
I guess gunicorn is more performant but why? What are the differences? If I have to do it programmatically would I have performance issues?
Upvotes: 1
Views: 6941
Reputation: 6736
One big difference is that gunicorn forks worker processes. In your example you pass the argument --workers=2
which will spawn 2 worker processes. Since Python has the Global Interpreter Lock (GIL), a single process running Eventlet can not take advantage of the performance of multiple processor cores while the multiple worker processes spawned by gunicorn can. If your application is CPU intensive, this might make a large improvement in performance. Of course, you could just launch multiple processes like your eventlet.wsgi example yourself.
The other answers here linked to some good resources for learning about the options.
Upvotes: 5
Reputation: 1123740
Both gunicorn
and the wsgi
module are implementations of a standard for hosting Python applications. That standard is called the Web Server Gateway Interface, or WSGI. There are many more such implementations.
Which one you pick depends on your specific needs, depending on your deployment target (what can be installed there), your memory and CPU constraints, performance metrics of the specific implementation, specific features the implementations offer, project security record (does the project support in-production deployments, number of security issues raised, response time to security issues), etc. We can't make that choice for you.
Also see:
bjoern
has not been updated in a while and as a project is going to require more Python knowledge to set up correctly.Upvotes: 3
Reputation: 11932
Indeed its performance and the way the system manages the process, the key metrics you should consider evaluating eventlet.wsgi vs gunicorn are:
you can read more about some python wsgi servers benchmark here and find out someone who managed to compare the ones you want to define the one you need.
also, related to this, you should consider process control when deploying on production.
Upvotes: 1