---
title: "Discussion on \"FastAPI `def` vs `async def`: When Your Endpoint Blocks Everything\" | Hashnode"
description: "Discussion on \"FastAPI `def` vs `async def`: When Your Endpoint Blocks Everything\". Ten concurrent 0.5 s sleeps: async def + time.sleep took 5016.7 ms and made /ping sit at p50 450.7 ms. Plain def and await asyncio.sleep both finished around 0.5 s with /ping under 2 ms."
url: "https://hashnode.com/posts/fastapi-def-vs-async-def-blocking-event-loop/6aed7dd4310621c7358a6ed9"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [FastAPI \`def\` vs \`async def\`: When Your Endpoint Blocks Everything](https://gowthammuthuvel.hashnode.dev/fastapi-def-vs-async-def-blocking-event-loop?utm_source=hashnode&utm_medium=feed)

Ten concurrent 0.5 s sleeps: async def + time.sleep took 5016.7 ms and made /ping sit at p50 450.7 ms. Plain def and await asyncio.sleep both finished around 0.5 s with /ping under 2 ms.

Nov 6 · 12 min read · gowthammuthuvel.hashnode.dev  
Read the article

-   [#fastapi](https://hashnode.com/tag/fastapi)
-   [#python](https://hashnode.com/tag/python)
-   [#async](https://hashnode.com/tag/async)
-   [#asyncio](https://hashnode.com/tag/asyncio)
-   [#backend](https://hashnode.com/tag/backend)
-   [#apis](https://hashnode.com/tag/apis)
-   [#uvicorn](https://hashnode.com/tag/uvicorn)
-   [#performance](https://hashnode.com/tag/performance)

## Written by

[Gowtham Muthuvel](https://hashnode.com/@GowthamMuthuvel)

@GowthamMuthuvel

  
[View profile](https://hashnode.com/@GowthamMuthuvel)

Full-stack developer | Java, Spring Boot, React | Senior Backend Developer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
