द लैब्स / Backend
BackendApplied~4h
A rate limiter that survives a burst
A token-bucket rate limiter you can drop in front of any endpoint: each key (user or API token) gets its own bucket that refills continuously over time and drains on every request. You prove it two ways — a burst above capacity gets rejected immediately, and a caller who paces requests under the refill rate never gets throttled.
यह क्या साबित करता है
वह पंक्ति जिसे आप साक्षात्कार में सही ठहरा सकते हैं।
रिज़्यूमे पंक्ति
Implemented a per-key token-bucket rate limiter (continuous refill, burst capacity, 429 on exhaustion) with a load test proving it caps bursts while passing steady traffic under the refill rate.
- Understands token-bucket vs fixed-window tradeoffs, not just the name
- Can reason about time-based state without relying on a cron job or sleep loop
- Designs a shared resource (the limiter) to be safe under concurrent callers
संक्षिप्त विवरण
आप चरण-दर-चरण क्या बनाते हैं।
- 01Each key gets a bucket with a max capacity and a refill rate (tokens/second).
- 02On each request: lazily compute tokens added since last check (elapsed * rate, capped at capacity), then attempt to remove 1 token.
- 03If a token is available, allow the request and persist the new token count + timestamp.
- 04If no token is available, reject with 429 and a Retry-After header computed from the refill rate.
- 05Buckets are independent per key — one key's traffic never affects another key's budget.
- 06Expose allow(key) -> { allowed: bool, remaining: number, retryAfterMs?: number }.
सबूत
यह तब पूरा होता है जब ये पास हो जाते हैं।
A burst of 2x capacity requests in one instant allows exactly `capacity` and rejects the rest
automated test
Requests paced at or under the refill rate are never rejected over a sustained run
automated test
Two different keys hitting the limiter concurrently do not affect each other's remaining count
automated test
A rejected request returns a Retry-After value that, once waited out, results in an allowed request
automated test
स्टैक
PythonRedis (or an in-memory store for the base version)
Sage Method
frame → map → decide → prove
आप रखते हैं
A reusable rate-limiter module + a passing burst/steady-state test suite