gunicorn 多種工作模式
gunicorn 支持如下4種工作模式
- Sync Workers
- Async Workers
- Tornado Workers
- AsyncIO workers
工作模式是通過work_class參數配置的值:缺省值: sync
- sync
- gevent
- eventlet
- tornado
- gaiohttp
- gthread
Sync Workers (sync)
最簡單的同步工作模式
Async Workers (gevent, eventlet)
gevent和eventlet都是基於Greenlet庫,利用python協程實現的
Tornado Workers (tornado)
利用python Tornado框架實現
AsyncIO Workers (gthread, gaiohttp)
gaiohttp利用aiohttp庫實現異步I/O,支持web socket
gthread采用的是線程工作模式,利用線程池管理連接
本文轉載自:https://www.jianshu.com/p/608a075e7d0e