Back to search

Sync vs async endpoints in FastAPI

Choose async for non-blocking I O and sync for blocking libraries or straightforward CPU-bound logic.

FastAPI Medium Theory

Sync vs async endpoints in FastAPI

Choose async for non-blocking I O and sync for blocking libraries or straightforward CPU-bound logic.

  • Both are supported
  • Wrong async usage can be slower
  • Match the endpoint to the dependency stack

Sync vs async endpoints in FastAPI