# Async vs sync route handlers

> When should a FastAPI route handler be async def and when should it be plain def? What happens if you get it wrong?

Canonical: https://www.internhack.in/learn/interview/fastapi-interview/fastapi-async-routes
Last updated: 2026-11-28

Difficulty: Intermediate

## Question

When should a FastAPI route handler be async def and when should it be plain def? What happens if you get it wrong?

*The full answer is for InternHack members. Open the page link above to read it.*

## Concepts covered

async def vs def, event loop, threadpool, blocking I/O, run_in_threadpool

Previous: [Dependency Injection in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-dependency-injection) · Next: [Authentication and JWT in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-authentication) · [All of FastAPI Interview](https://www.internhack.in/learn/interview/fastapi-interview)

## More FastAPI Interview questions

- [Error handling and HTTPException](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-error-handling)
- [Middleware in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-middleware)
- [Database integration with SQLAlchemy](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-database)
- [Background tasks in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-background-tasks)
- [File uploads in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-file-upload)
- [WebSockets in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-websockets)

## Related

- [Learn](https://www.internhack.in/learn)
- [Interview Prep](https://www.internhack.in/learn/interview)
- [FastAPI Interview](https://www.internhack.in/learn/interview/fastapi-interview)
