Code RoomRedis rate limiter
HardPrep Room Coding #4268

Redis rate limiter

Vibe & agenticNetworking & APIsDistributed systemsSenior–Staff~26 min

Greenfield: you're directing an AI agent to build an API rate limiter as Express middleware in TypeScript, backed by Redis, enforcing per-API-key limits (e.g. 100 req/min) across a horizontally-scaled fleet. Lay out the build plan: the algorithm choice (fixed window vs. sliding window vs. token bucket), how you keep it atomic across instances, response headers, and acceptance criteria. What does a careless 'add rate limiting' prompt get wrong in a multi-instance deployment?

Implement
decide_rate_limit(instance_ids: list[str], request_ms: list[int], limit: int, window_ms: int, shared_counter: bool) → list[str]
Examples
in[["a","b","c","a"],[0,10,20,30],3,1000,true]out["allow|2","allow|1","allow|0","deny|970"]
in[["a","b","c","a"],[0,10,20,30],3,1000,false]out["allow|2","allow|2","allow|2","allow|1"]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 26 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.