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,以達到並發與並行的最好效果。

如果大家有其他見解請留言。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM