Interview Prep/Build Tools (Java, Node.js, Python, .NET)/Python builds (pip, venv, requirements.txt)

What is the difference between WSGI and ASGI?

IntermediateConceptPython builds (pip, venv, requirements.txt)
Answer

Short answer

Both are standards for how a Python web server talks to a Python web app. WSGI is synchronous — one request per worker thread at a time (Flask, classic Django; servers like gunicorn, uWSGI). ASGI is asynchronous — one worker can handle many concurrent connections and supports WebSockets (FastAPI, Starlette, async Django; servers like uvicorn, hypercorn, daphne).

Table

WSGI ASGI
Style Synchronous Async (async def)
Frameworks Flask, Django FastAPI, Starlette, Django (async)
Servers gunicorn, uWSGI uvicorn, hypercorn, daphne
WebSockets No Yes
Good for Classic request/response apps Many slow I/O calls, streaming, websockets

Example

gunicorn app:app                                     # WSGI (Flask)
uvicorn main:app --host 0.0.0.0 --port 8000          # ASGI (FastAPI)
gunicorn -k uvicorn.workers.UvicornWorker main:app   # ASGI app, gunicorn process management

What to say in the interview

"WSGI is the synchronous interface used by Flask and Django with gunicorn; ASGI is the async successor used by FastAPI with uvicorn, which supports high concurrency and websockets. For FastAPI in production we often run uvicorn workers under gunicorn."

All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: Python apps: pip, venv & requirements.txt

More on Python builds (pip, venv, requirements.txt)