ASGI, asyncio & Why Uvicorn Exists
ASGI: The Async Successor to WSGI
Uvicorn is a lightning-fast ASGI server for async Python web apps. WSGI's synchronous, one-request-per-thread model has no native concept of async handlers or persistent connections like WebSockets — ASGI (Asynchronous Server Gateway Interface) was designed specifically to fill that gap, and Uvicorn is the most common way to run an ASGI application.
asyncio Underneath
Uvicorn is built on Python's asyncio event loop, letting many I/O-bound connections be handled concurrently within a single process via coroutines rather than one thread per connection. uvloop (a fast asyncio replacement built on libuv) and httptools (a fast C-based HTTP parser) are the optional accelerated dependencies behind Uvicorn's performance edge over pure-Python implementations.
Running an App
uvicorn main:app --reload # dev: module:variable + auto-restart on change
uvicorn main:app --workers 4 # production: multiple worker processesmain:app points Uvicorn at the ASGI callable to serve. --reload is a dev-only convenience (file-watching overhead not wanted in production). --workers spawns multiple processes, each with its own event loop, since a single async process is still bound by the GIL for CPU-bound work and represents a single point of failure.
Server, Not Framework
Uvicorn is described as a server, not a framework — it accepts connections and speaks the ASGI protocol, while routing, request parsing into higher-level objects, and business logic are the framework's job (FastAPI, Starlette). Being ASGI-standard-compliant, Uvicorn is framework-agnostic — it can serve any ASGI application, not just FastAPI.
Keep your own version of these notes — editable, searchable, and organised by your stack.
Start free