Bird
0
0

Given this fixed window rate limiter code snippet:

medium📝 Predict Output Q5 of 15
Rest API - Rate Limiting and Throttling

Given this fixed window rate limiter code snippet:

window_size = 60
limit = 5
requests = [10, 20, 30, 40, 50, 55]

Which request will be blocked?

AThe sixth request at 55 seconds
BThe fifth request at 50 seconds
CThe first request at 10 seconds
DNo requests are blocked
Step-by-Step Solution
Solution:
  1. Step 1: Count requests in the 0-60 seconds window

    Requests at 10, 20, 30, 40, 50, 55 seconds all fall in the same 60-second window.
  2. Step 2: Compare count to limit

    Limit is 5 requests; the sixth request at 55 seconds exceeds limit and is blocked.
  3. Final Answer:

    The sixth request at 55 seconds -> Option A
  4. Quick Check:

    Requests > limit in window = Block excess [OK]
Quick Trick: Block requests exceeding limit in same window [OK]
Common Mistakes:
  • Allowing all requests regardless of limit
  • Blocking earlier requests incorrectly
  • Miscounting requests per window

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes