WSGI vs ASGI: what does ASGI add?
Options
- Template rendering for HTML pages on the server side
- Async support, including WebSockets and long-lived connections (Correct option)
- An ORM that maps database tables to Python classes
- Static file serving, and nothing else on top of WSGI
Answer
Async support including WebSockets and long-lived connections
Why
WSGI and ASGI are standards for how a Python web server talks to your web app.
WSGI (Flask, classic Django, served by Gunicorn) is synchronous: one request per worker at a time, plain request/response.
ASGI (FastAPI, modern Django, served by Uvicorn) supports async code, WebSockets and long-lived connections.
Remember
WSGI = sync. ASGI = async + WebSockets.