Sunday, June 28, 2026

Flow chart of apache+uvcorn infrastructure

An Apache + Uvicorn infrastructure uses Apache as a reverse proxy to accept incoming HTTP/HTTPS traffic and safely route it to the Uvicorn ASGI server running your Python application (like FastAPI or Starlette). [1, 2, 3, 4]
The complete request flow from the client to your Python code works as follows:
text
[ Client (Browser / App) ]
           │
           ▼ (HTTP Request)
┌────────────────────────────────────────────────────────┐
│ Apache HTTP Server                                     │
│   • mod_proxy_http / mod_proxy                         │
│   • SSL/TLS Termination                                │
│   • Static file serving (optional)                     │
└────────────────────────────────────────────────────────┘
           │
           ▼ (Reverse Proxy / Forwarded Request)
┌────────────────────────────────────────────────────────┐
│ Uvicorn (ASGI Server)                                  │
│   • Uvicorn Master Process                             │
│   • Uvicorn Worker Process(es)                         │
└────────────────────────────────────────────────────────┘
           │
           ▼ (ASGI Interface)
┌────────────────────────────────────────────────────────┐
│ Python Application                                     │
│   • FastAPI / Starlette / Custom code                  │
└────────────────────────────────────────────────────────┘
Detailed Step-by-Step Flow
  1. Client Request: A user's browser or mobile application sends an HTTP or HTTPS request to your domain.
  2. Apache (Reverse Proxy): The request hits Apache first. Apache acts as the public-facing edge. It can handle SSL/TLS termination, set security headers, and quickly serve static files (like images or CSS) without involving the Python backend. [1, 2]
  3. Apache to Uvicorn Proxy: Apache uses the ProxyPass directive (via mod_proxy_http) to forward the HTTP request over a local port (e.g., http://127.0.0.1:8000) to the Uvicorn server. [1, 2]
  4. Uvicorn Worker: Uvicorn's master/worker model receives the request. The Uvicorn event loop processes the request asynchronously using standard ASGI protocols. [1, 2]
  5. Python App Execution: The framework (e.g., FastAPI) executes your business logic, queries databases, and returns the response back through Uvicorn and Apache to the end client. [1, 2, 3, 4]

No comments:

Blog Archive

Followers