Repaso
EspaƱol
Backend & APIsIntermediateAPI-17

WSGI vs ASGI: what does ASGI add?

Options

  1. Template rendering for HTML pages on the server side
  2. Async support, including WebSockets and long-lived connections (Correct option)
  3. An ORM that maps database tables to Python classes
  4. 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.

Key terms

Practice this question in Repaso