Performance: DRF authentication (Token, JWT)
MEDIUM IMPACT
This affects the server response time and client perceived latency during API authentication.
Using JWT authentication with stateless token validation: from rest_framework_simplejwt.authentication import JWTAuthentication from rest_framework.views import APIView class MyView(APIView): authentication_classes = [JWTAuthentication] # Token is validated cryptographically without DB lookup
Using Django REST Framework TokenAuthentication with database lookup on every request: from rest_framework.authentication import TokenAuthentication from rest_framework.views import APIView class MyView(APIView): authentication_classes = [TokenAuthentication] # Each request triggers a DB query to validate the token
| Pattern | DB Queries | Token Validation Cost | Latency Impact | Verdict |
|---|---|---|---|---|
| DRF TokenAuthentication | 1 query/request | DB lookup | Higher latency per request | [X] Bad |
| JWT Authentication | 0 queries/request | Cryptographic check | Lower latency, scalable | [OK] Good |