Performance: Why background tasks matter
HIGH IMPACT
Background tasks affect page load speed and user interaction responsiveness by offloading heavy work from the main request cycle.
from celery import shared_task @shared_task def send_email_task(subject, message, from_email, recipient_list): send_mail(subject, message, from_email, recipient_list) # In view send_email_task.delay(subject, message, from_email, recipient_list) return HttpResponse('Email queued')
def send_email(request): # slow email sending inside request send_mail(subject, message, from_email, recipient_list) return HttpResponse('Email sent')
| Pattern | Server Blocking | Response Time | User Perceived Speed | Verdict |
|---|---|---|---|---|
| Synchronous slow task in request | Blocks server thread | High (hundreds ms to seconds) | Slow response, poor INP | [X] Bad |
| Background task with Celery or similar | No blocking in request | Low (milliseconds) | Fast response, good INP | [OK] Good |