GunicornPython 的 WSGI 服務(wù)器
Gunicorn 綠色獨(dú)角獸'是一個(gè)Python WSGI UNIX的HTTP服務(wù)器。這是一個(gè)pre-fork worker的模型,從Ruby的獨(dú)角獸(Unicorn )項(xiàng)目移植。該Gunicorn服務(wù)器大致與各種Web框架兼容,只需非常簡(jiǎn)單的執(zhí)行,輕量級(jí)的資源消耗,以及相當(dāng)迅速。
結(jié)構(gòu)圖:
與 uWSGI 的性能比較:
特點(diǎn):
本身支持WSGI、Django、Paster
自動(dòng)輔助進(jìn)程管理
簡(jiǎn)單的 Python配置
允許配置多個(gè)工作環(huán)境
各種服務(wù)器的可擴(kuò)展鉤子
與 Python 2.x > = 2.5,3.x >= 3.2 兼容
安裝:
$ pip install gunicorn
$ cat myapp.py
def app(environ, start_response):
data = b"Hello, World!\n"
start_response("200 OK", [
("Content-Type", "text/plain"),
("Content-Length", str(len(data)))
])
return iter([data])
$ gunicorn -w 4 myapp:app
[2014-09-10 10:22:28 +0000] [30869] [INFO] Listening at: http://127.0.0.1:8000 (30869)
[2014-09-10 10:22:28 +0000] [30869] [INFO] Using worker: sync
[2014-09-10 10:22:28 +0000] [30874] [INFO] Booting worker with pid: 30874
[2014-09-10 10:22:28 +0000] [30875] [INFO] Booting worker with pid: 30875
[2014-09-10 10:22:28 +0000] [30876] [INFO] Booting worker with pid: 30876
[2014-09-10 10:22:28 +0000] [30877] [INFO] Booting worker with pid: 30877評(píng)論
圖片
表情
