Uvicorn vs Gunicorn
作者:互联网
最近新接触了一个FastAPI的小项目,发现HTTP SERVER是采用的docker,对应的基础镜像是tiangolo/uvicorn-gunicorn-fastapi:python3.7。
这里有个问题,FastAPI官网demo中使用的是uvicorn,这里的tiangolo/uvicorn-gunicorn-fastapi:python3.7应该是uvicorn+gunicorn做HTTP SERVER,为何?
关于Uvicorn和Gunicorn的区别,大家可以参考
https://stackshare.io/stackups/gunicorn-vs-unicorn
其要点是:
Gunicorn是"A Python WSGI HTTP Server for UNIX";
Uvicorn 是"Rack HTTP server for fast clients and Unix"
这里还是有些疑问,因为Uvicorn官网对Uvicorn的定义是:
Uvicorn is a lightning-fast ASGI server implementation, using uvloop and httptools.
这一点和Gunicorn的定义就很接近了。
从tiangolo/uvicorn-gunicorn-fastapi:python3.7的介绍(https://github.com/tiangolo/uvicorn-gunicorn-docker)中可以看到:
Uvicorn
Uvicorn is a lightning-fast "ASGI" server.
It runs asynchronous Python web code in a single process.
Gunicorn
You can use Gunicorn to manage Uvicorn and run multiple of these concurrent processes.
That way, you get the best of concurrency and parallelism.
这里把Uvicorn描述为单进程的ASGI server,而Gunicorn是管理运行多个Uvicorn,以达到并发与并行的最好效果。
如果大家有其他见解请留言。
标签:HTTP,gunicorn,uvicorn,vs,tiangolo,Uvicorn,Gunicorn 来源: https://www.cnblogs.com/LeoGIS/p/14107024.html