Bird
Raised Fist0

Given a token bucket with max_tokens = 5, refill_rate = 1 token/second, and an empty bucket at time 0, what is the number of tokens available at time 3 seconds?

medium📝 Predict Output Q13 of Q15
Rest API - Rate Limiting and Throttling

Given a token bucket with max_tokens = 5, refill_rate = 1 token/second, and an empty bucket at time 0, what is the number of tokens available at time 3 seconds?

A3 tokens
B5 tokens
C0 tokens
D1 token
Step-by-Step Solution
Solution:
  1. Step 1: Calculate tokens refilled after 3 seconds

    Since refill rate is 1 token per second, after 3 seconds, 3 tokens are added.
  2. Step 2: Check max tokens limit

    The bucket max is 5 tokens, so 3 tokens fit without exceeding the max.
  3. Final Answer:

    3 tokens -> Option A
  4. Quick Check:

    3 seconds * 1 token/sec = 3 tokens [OK]
Quick Trick: Multiply seconds by refill rate, cap at max tokens [OK]
Common Mistakes:
MISTAKES
  • Assuming bucket fills instantly to max
  • Ignoring max token limit
  • Using refill rate incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes