Skip to content

💽 👨‍🏭 - 🐁 ⏮️ Uvicorn

➡️ ✅ 🔙 👈 🛠️ 🔧 ⚪️➡️ ⏭:

  • 💂‍♂ - 🇺🇸🔍
  • 🏃‍♂ 🔛 🕴
  • 🧬 (🔢 🛠️ 🏃)
  • 💾
  • ⏮️ 🔁 ⏭ ▶️

🆙 👉 ☝, ⏮️ 🌐 🔰 🩺, 👆 ✔️ 🎲 🏃‍♂ 💽 📋 💖 Uvicorn, 🏃‍♂ 👁 🛠️.

🕐❔ 🛠️ 🈸 👆 🔜 🎲 💚 ✔️ 🧬 🛠️ ✊ 📈 💗 🐚 & 💪 🍵 🌅 📨.

👆 👀 ⏮️ 📃 🔃 🛠️ 🔧, 📤 💗 🎛 👆 💪 ⚙️.

📥 👤 🔜 🎦 👆 ❔ ⚙️ 🐁 ⏮️ Uvicorn 👨‍🏭 🛠️.

Info

🚥 👆 ⚙️ 📦, 🖼 ⏮️ ☁ ⚖️ Kubernetes, 👤 🔜 💬 👆 🌅 🔃 👈 ⏭ 📃: FastAPI 📦 - ☁.

🎯, 🕐❔ 🏃 🔛 Kubernetes 👆 🔜 🎲 🚫 💚 ⚙️ 🐁 & ↩️ 🏃 👁 Uvicorn 🛠️ 📍 📦, ✋️ 👤 🔜 💬 👆 🔃 ⚫️ ⏪ 👈 📃.

🐁 ⏮️ Uvicorn 👨‍🏭

🐁 ✴️ 🈸 💽 ⚙️ 🇨🇻 🐩. 👈 ⛓ 👈 🐁 💪 🍦 🈸 💖 🏺 & ✳. 🐁 ⚫️ 🚫 🔗 ⏮️ FastAPI, FastAPI ⚙️ 🆕 🔫 🐩.

✋️ 🐁 🐕‍🦺 👷 🛠️ 👨‍💼 & 🤝 👩‍💻 💬 ⚫️ ❔ 🎯 👨‍🏭 🛠️ 🎓 ⚙️. ⤴️ 🐁 🔜 ▶️ 1️⃣ ⚖️ 🌖 👨‍🏭 🛠️ ⚙️ 👈 🎓.

& Uvicorn ✔️ 🐁-🔗 👨‍🏭 🎓.

⚙️ 👈 🌀, 🐁 🔜 🚫 🛠️ 👨‍💼, 👂 🔛 & 📢. & ⚫️ 🔜 📶 📻 👨‍🏭 🛠️ 🏃 Uvicorn 🎓.

& ⤴️ 🐁-🔗 Uvicorn 👨‍🏭 🎓 🔜 🈚 🏭 📊 📨 🐁 🔫 🐩 FastAPI ⚙️ ⚫️.

❎ 🐁 & Uvicorn

$ pip install "uvicorn[standard]" gunicorn

---> 100%

👈 🔜 ❎ 👯‍♂️ Uvicorn ⏮️ standard ➕ 📦 (🤚 ↕ 🎭) & 🐁.

🏃 🐁 ⏮️ Uvicorn 👨‍🏭

⤴️ 👆 💪 🏃 🐁 ⏮️:

$ gunicorn main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:80

[19499] [INFO] Starting gunicorn 20.1.0
[19499] [INFO] Listening at: http://0.0.0.0:80 (19499)
[19499] [INFO] Using worker: uvicorn.workers.UvicornWorker
[19511] [INFO] Booting worker with pid: 19511
[19513] [INFO] Booting worker with pid: 19513
[19514] [INFO] Booting worker with pid: 19514
[19515] [INFO] Booting worker with pid: 19515
[19511] [INFO] Started server process [19511]
[19511] [INFO] Waiting for application startup.
[19511] [INFO] Application startup complete.
[19513] [INFO] Started server process [19513]
[19513] [INFO] Waiting for application startup.
[19513] [INFO] Application startup complete.
[19514] [INFO] Started server process [19514]
[19514] [INFO] Waiting for application startup.
[19514] [INFO] Application startup complete.
[19515] [INFO] Started server process [19515]
[19515] [INFO] Waiting for application startup.
[19515] [INFO] Application startup complete.

➡️ 👀 ⚫️❔ 🔠 👈 🎛 ⛓:

  • main:app: 👉 🎏 ❕ ⚙️ Uvicorn, main ⛓ 🐍 🕹 📛 "main",, 📁 main.py. & app 📛 🔢 👈 FastAPI 🈸.

    • 👆 💪 🌈 👈 main:app 🌓 🐍 import 📄 💖:

      from main import app
      
    • , ❤ main:app 🔜 🌓 🐍 import 🍕 from main import app.

    • --workers: 🔢 👨‍🏭 🛠️ ⚙️, 🔠 🔜 🏃 Uvicorn 👨‍🏭, 👉 💼, 4️⃣ 👨‍🏭.
    • --worker-class: 🐁-🔗 👨‍🏭 🎓 ⚙️ 👨‍🏭 🛠️.
    • 📥 👥 🚶‍♀️ 🎓 👈 🐁 💪 🗄 & ⚙️ ⏮️:

      import uvicorn.workers.UvicornWorker
      
  • --bind: 👉 💬 🐁 📢 & ⛴ 👂, ⚙️ ❤ (:) 🎏 📢 & ⛴.

    • 🚥 👆 🏃‍♂ Uvicorn 🔗, ↩️ --bind 0.0.0.0:80 (🐁 🎛) 👆 🔜 ⚙️ --host 0.0.0.0 & --port 80.

🔢, 👆 💪 👀 👈 ⚫️ 🎦 🕹 (🛠️ 🆔) 🔠 🛠️ (⚫️ 🔢).

👆 💪 👀 👈:

  • 🐁 🛠️ 👨‍💼 ▶️ ⏮️ 🕹 19499 (👆 💼 ⚫️ 🔜 🎏 🔢).
  • ⤴️ ⚫️ ▶️ Listening at: http://0.0.0.0:80.
  • ⤴️ ⚫️ 🔍 👈 ⚫️ ✔️ ⚙️ 👨‍🏭 🎓 uvicorn.workers.UvicornWorker.
  • & ⤴️ ⚫️ ▶️ 4️⃣ 👨‍🏭, 🔠 ⏮️ 🚮 👍 🕹: 19511, 19513, 19514, & 19515.

🐁 🔜 ✊ 💅 🛠️ ☠️ 🛠️ & 🔁 🆕 🕐 🚥 💚 🚧 🔢 👨‍🏭. 👈 ℹ 🍕 ⏮️ 🔧 ⚪️➡️ 📇 🔛.

👐, 👆 🔜 🎲 💚 ✔️ 🕳 🏞 ⚒ 💭 ⏏ 🐁 🚥 💪, & 🏃 ⚫️ 🔛 🕴, ♒️.

Uvicorn ⏮️ 👨‍🏭

Uvicorn ✔️ 🎛 ▶️ & 🏃 📚 👨‍🏭 🛠️.

👐, 🔜, Uvicorn 🛠️ 🚚 👨‍🏭 🛠️ 🌅 📉 🌘 🐁. , 🚥 👆 💚 ✔️ 🛠️ 👨‍💼 👉 🎚 (🐍 🎚), ⤴️ ⚫️ 💪 👍 🔄 ⏮️ 🐁 🛠️ 👨‍💼.

🙆 💼, 👆 🔜 🏃 ⚫️ 💖 👉:

$ uvicorn main:app --host 0.0.0.0 --port 8080 --workers 4
<font color="#A6E22E">INFO</font>:     Uvicorn running on <b>http://0.0.0.0:8080</b> (Press CTRL+C to quit)
<font color="#A6E22E">INFO</font>:     Started parent process [<font color="#A1EFE4"><b>27365</b></font>]
<font color="#A6E22E">INFO</font>:     Started server process [<font color="#A1EFE4">27368</font>]
<font color="#A6E22E">INFO</font>:     Waiting for application startup.
<font color="#A6E22E">INFO</font>:     Application startup complete.
<font color="#A6E22E">INFO</font>:     Started server process [<font color="#A1EFE4">27369</font>]
<font color="#A6E22E">INFO</font>:     Waiting for application startup.
<font color="#A6E22E">INFO</font>:     Application startup complete.
<font color="#A6E22E">INFO</font>:     Started server process [<font color="#A1EFE4">27370</font>]
<font color="#A6E22E">INFO</font>:     Waiting for application startup.
<font color="#A6E22E">INFO</font>:     Application startup complete.
<font color="#A6E22E">INFO</font>:     Started server process [<font color="#A1EFE4">27367</font>]
<font color="#A6E22E">INFO</font>:     Waiting for application startup.
<font color="#A6E22E">INFO</font>:     Application startup complete.

🕴 🆕 🎛 📥 --workers 💬 Uvicorn ▶️ 4️⃣ 👨‍🏭 🛠️.

👆 💪 👀 👈 ⚫️ 🎦 🕹 🔠 🛠️, 27365 👪 🛠️ (👉 🛠️ 👨‍💼) & 1️⃣ 🔠 👨‍🏭 🛠️: 27368, 27369, 27370, & 27367.

🛠️ 🔧

📥 👆 👀 ❔ ⚙️ 🐁 (⚖️ Uvicorn) 🛠️ Uvicorn 👨‍🏭 🛠️ 🔁 🛠️ 🈸, ✊ 📈 💗 🐚 💽, & 💪 🍦 🌅 📨.

⚪️➡️ 📇 🛠️ 🔧 ⚪️➡️ 🔛, ⚙️ 👨‍🏭 🔜 ✴️ ℹ ⏮️ 🧬 🍕, & 🐥 🍖 ⏮️ , ✋️ 👆 💪 ✊ 💅 🎏:

  • 💂‍♂ - 🇺🇸🔍
  • 🏃‍♂ 🔛 🕴
  • 🧬 (🔢 🛠️ 🏃)
  • 💾
  • ⏮️ 🔁 ⏭ ▶️

📦 & ☁

⏭ 📃 🔃 FastAPI 📦 - ☁ 👤 🔜 💬 🎛 👆 💪 ⚙️ 🍵 🎏 🛠️ 🔧.

👤 🔜 🎦 👆 🛂 ☁ 🖼 👈 🔌 🐁 ⏮️ Uvicorn 👨‍🏭 & 🔢 📳 👈 💪 ⚠ 🙅 💼.

📤 👤 🔜 🎦 👆 ❔ 🏗 👆 👍 🖼 ⚪️➡️ 🖌 🏃 👁 Uvicorn 🛠️ (🍵 🐁). ⚫️ 🙅 🛠️ & 🎲 ⚫️❔ 👆 🔜 💚 🕐❔ ⚙️ 📎 📦 🧾 ⚙️ 💖 Kubernetes.

🌃

👆 💪 ⚙️ 🐁 (⚖️ Uvicorn) 🛠️ 👨‍💼 ⏮️ Uvicorn 👨‍🏭 ✊ 📈 👁-🐚 💽, 🏃 💗 🛠️ 🔗.

👆 💪 ⚙️ 👉 🧰 & 💭 🚥 👆 ⚒ 🆙 👆 👍 🛠️ ⚙️ ⏪ ✊ 💅 🎏 🛠️ 🔧 👆.

✅ 👅 ⏭ 📃 💡 🔃 FastAPI ⏮️ 📦 (✅ ☁ & Kubernetes). 👆 🔜 👀 👈 👈 🧰 ✔️ 🙅 🌌 ❎ 🎏 🛠️ 🔧 👍. 👶