How to Approach

What you should do next

With requirements agreed, publish a timeboxed plan before drawing classes. Interviewers score the plan as much as the code.


45-minute timeline

Phase Clock Output
Requirements 0:00 – 5:00 Functional + NFR + out-of-scope
Entities 5:00 – 12:00 Config, Result, Type
Interfaces 12:00 – 20:00 Strategy, ClockProvider, Manager, Factory
Algorithm trade-offs 20:00 – 25:00 Comparison table + pick
Implementation 25:00 – 38:00 Token Bucket + Manager + thread safety
Testing 38:00 – 44:00 Unit plan + concurrency stress idea
Wrap-up 44:00 – 45:00 Metrics, eviction, distributed next steps

If they only want one algorithm, still name the others and why you did not pick them.


Delivery order (matches this course)

  1. Entities — immutable Config and Result
  2. Contracts — Strategy first, then Manager that routes by priority
  3. One algorithm deeply — Token Bucket with lazy refill
  4. Thread safety — per-client lock, not a global lock
  5. Optional — other algorithms behind the same interface
  6. Scale-out talk — why in-memory fails with multiple pods

Patterns you will use (name them)

  • StrategyRateLimiterStrategy for algorithms
  • FactoryRateLimiterFactory maps RateLimiterType → implementation
  • Immutable value objectsRateLimitResult, RateLimiterConfig
  • Clock injectionClockProvider so tests never need Thread.sleep

Where concurrency fits

Do not lead with Redis. Lead with: check-and-consume must be atomic for one client; different clients should not block each other. Redis is the answer to shared quota across JVMs, not the first sentence of the interview.