Performance: Concurrent task execution
HIGH IMPACT
Concurrent task execution affects how quickly a FastAPI server can handle multiple requests or background tasks without blocking, improving responsiveness and throughput.
from fastapi import FastAPI import asyncio app = FastAPI() @app.get("/async-task") async def async_task(): await asyncio.sleep(5) # non-blocking sleep return {"message": "Task done"}
from fastapi import FastAPI import time app = FastAPI() @app.get("/sync-task") def sync_task(): time.sleep(5) # blocking sleep return {"message": "Task done"}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous blocking task | N/A | N/A | N/A | [X] Bad |
| Asynchronous non-blocking task | N/A | N/A | N/A | [OK] Good |