Bird
0
0

Given this view with throttling applied:

medium📝 component behavior Q13 of 15
Django - DRF Advanced Features
Given this view with throttling applied:
from rest_framework.throttling import UserRateThrottle

class MyThrottle(UserRateThrottle):
    rate = '3/minute'

class MyView(APIView):
    throttle_classes = [MyThrottle]

    def get(self, request):
        return Response({'message': 'Hello'})

What happens if a user makes 4 GET requests within one minute?
AThe 4th request is delayed but eventually succeeds
BAll 4 requests succeed with status 200
CThe 4th request is blocked with a 429 Too Many Requests error
DThe server crashes due to too many requests
Step-by-Step Solution
Solution:
  1. Step 1: Understand throttle rate and behavior

    The throttle allows 3 requests per minute per user; the 4th exceeds the limit.
  2. Step 2: Identify response to exceeding limit

    When limit is exceeded, Django REST Framework returns HTTP 429 error blocking the request.
  3. Final Answer:

    The 4th request is blocked with a 429 Too Many Requests error -> Option C
  4. Quick Check:

    Requests > rate limit = 429 error [OK]
Quick Trick: Requests over limit get 429 error [OK]
Common Mistakes:
MISTAKES
  • Assuming all requests succeed
  • Thinking requests get delayed instead of blocked
  • Believing server crashes on too many requests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes