Syllabus

Interview walkthrough: clarify the prompt, design Strategy + Manager, implement algorithms, then harden for concurrency and multi-instance.

The interview

The prompt lands. Clarify requirements and set a delivery plan before you pick an algorithm.

  1. 1The Interview Prompt
  2. 2Clarify Requirements
  3. 3How to Approach

Design

Entities, Strategy contracts, Manager, and Factory — what you put on the board before coding.

  1. 4Entities & Config
  2. 5Strategy & Clock

Implement core

Wire Result, Config, Factory, and Manager with client > API > default priority.

  1. 6Core Skeleton

Algorithms

Token Bucket first, then fixed/sliding windows and Leaky Bucket — trade-offs out loud.

  1. 7Token Bucket
  2. 8Fixed & Sliding Windows
  3. 9Leaky Bucket

Concurrency

Per-client locks, ConcurrentHashMap, and a stress test that proves exactly `limit` succeed.

  1. 10Thread Safety

Multi-instance

Why in-memory quotas split across pods — Redis and DB sketches for shared counters.

  1. 11Why In-Memory Fails
  2. 12Redis & DB Limiting

Ship it

Decision matrix and how to run the `hub/scripts/rate-limiter-sourced/` project.

  1. 13Decision Matrix & Run