FastAPI runs on ASGI. Choose the function type by what it waits on: Write When Why async def you await async libraries (httpx, asyncpg, aiofiles) runs on the event loop def blocking libraries (requests, most DB drivers) runs in a thread pool automatically Never call blocking code (time.sleep, requests.get) inside async def — it freezes every request. Concurrency inside a request await asyncio.gather(a(), b()) runs independent I/O at the same time. Background tasks BackgroundTasks runs a function after the response is sent — fine for emails or audit logs. For heavy or retry-able work use a queue (Celery, RQ, Arq).