Skip to content
Preptima
hardDesignScenarioMidSeniorStaff

Your rate limiter has to work across twenty gateway instances. What does Redis do, and what breaks first?

Redis gives twenty gateways one counter mutated atomically through INCR or a Lua script, so rate limiting is fleet-wide. What breaks first is usually latency, not throughput: a slow Redis stalls every request for its timeout. Hot keys, caller clocks inside scripts and counts lost on async failover follow.

5 min readUpdated 2026-10-10Target archetype: Big Tech, Product Startup

Answer

Short answer

Redis is the shared counter. Twenty gateways cannot each count locally, or a 100-a-minute limit becomes 2,000; with Redis, every instance mutates one key atomically, through INCR or a Lua script, so rate limiting holds across the fleet. What breaks first is rarely raw throughput. It is latency: a slow Redis makes every request wait for the limiter's timeout. Hot keys, gateway clocks passed into scripts, and increments lost on failover come next.

Was this answer helpful?

Likely follow-ups

  • Your token-bucket script takes the current time as an argument from each gateway. One gateway's clock is two seconds fast. What does that tenant get?
  • How would you split one tenant's hot limiter key across shards, and what accuracy do you give up?
  • The Redis primary fails over and the replica is missing the last second of increments. Which limits does that matter for?
  • How do you choose the timeout on the gateway's call to the limiter store, and what number do you measure first?

Related questions

Further reading

Related Topics