Performance: Async views basics
MEDIUM IMPACT
This affects server response time and how quickly the browser receives the first byte, impacting page load speed.
async def my_view(request): data = await slow_io_operation_async() return HttpResponse(data)
def my_view(request): data = slow_io_operation() return HttpResponse(data)
| Pattern | Server Blocking | Concurrency | Response Time | Verdict |
|---|---|---|---|---|
| Synchronous view with blocking I/O | High (blocks worker) | Low | Slower under load | [X] Bad |
| Async view with await on I/O | Low (non-blocking) | High | Faster under load | [OK] Good |