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
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
Implement a distributed rate limiter that works across multiple API servers.