intermediateTop 30 Scenario-Based Questions
Implement a distributed rate limiter that works across multiple API servers.
Redis-based token bucket: 1) Per request: INCR ratelimit:{userId}:{minuteTimestamp} result = INCR if result == 1: EXPIRE ratelimit:{userId}:{minuteTimestamp} 60. 2) Check: if result > maxRequests: return 429. 3) Lua script (atomic): local result = redis.call('INCR', KEYS[1]) if result == 1 then redis.call('EXPIRE', KEYS[1], 60) end if result > ARGV[1] then return 0 else return 1 end. 4) Spring: Re
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response