← New search

Other meanings of Uvicorn

Web Frameworks

Uvicorn

Uvicorn is a lightning-fast ASGI server implementation for Python, built on uvloop and httptools. It is designed to serve asynchronous web applications and is the default server for FastAPI and Starlette.

2017
First release
Year
MIT
License
License
Python 3.8+
Requires
Python version
~10k
GitHub stars
Popularity
1

Core architecture

Uvicorn implements the ASGI (Asynchronous Server Gateway Interface) specification, which standardizes communication between Python web servers and applications. Unlike WSGI, ASGI supports asynchronous request handling, WebSockets, and HTTP/2. Uvicorn leverages uvloop, a drop-in replacement for Python's asyncio event loop, and httptools for fast HTTP parsing, achieving high throughput and low latency.

It runs a single worker process by default, but can be scaled with multiple workers using the --workers flag, which spawns separate processes. Uvicorn also supports hot reload during development via the --reload option, watching for file changes and restarting the server automatically.1

2

Adoption and ecosystem

Uvicorn is the recommended server for FastAPI and Starlette, two popular Python web frameworks. Its performance and simplicity have made it a standard choice for deploying async Python applications in production. Many cloud platforms, including Heroku and DigitalOcean, provide guides for deploying Uvicorn-based apps.2

It integrates seamlessly with process managers like Gunicorn, where Uvicorn can be used as a worker class to combine Gunicorn's process management with Uvicorn's async capabilities. This hybrid approach is common in production deployments to handle multiple workers and graceful restarts.

3

Lesser-known aspects

Uvicorn supports running as a Unix socket server, which is useful for reverse proxy setups like Nginx. It also includes a --uds option for binding to a Unix domain socket. Additionally, Uvicorn can serve static files directly when used with Starlette's StaticFiles middleware, though it is not a full static file server.

Another niche feature is the ability to run Uvicorn inside an existing asyncio event loop, allowing it to be embedded in larger applications. This is achieved by using the uvicorn.Server class directly, which gives developers fine-grained control over the server lifecycle. Uvicorn also supports TLS/SSL termination natively, with options for specifying certificates and keys.3

4

Performance and benchmarks

In benchmark tests, Uvicorn consistently outperforms traditional WSGI servers like Gunicorn with sync workers, often handling tens of thousands of requests per second on modest hardware. Its use of uvloop and httptools reduces overhead, making it comparable to Node.js in raw throughput.4

However, performance can vary depending on the application's workload and the number of workers. Uvicorn's documentation emphasizes that for CPU-bound tasks, multiple workers are necessary to utilize multiple cores, as a single worker is limited to one core due to Python's GIL. For I/O-bound tasks, a single worker can handle many concurrent connections efficiently.5

Glossary

ASGI
Asynchronous Server Gateway Interface, a specification for async web servers and applications in Python.
uvloop
A fast, drop-in replacement for asyncio's event loop, written in Cython.
httptools
A Python library for fast HTTP parsing, used by Uvicorn.
WSGI
Web Server Gateway Interface, the older synchronous counterpart to ASGI.

Uvicorn is actively maintained by the Encode organization and is part of the broader async Python ecosystem.