Place gateway middleware calling a sharded Redis cluster running atomic Lua scripts (token bucket or sliding-window counter), returning X-RateLimit-Remaining and Retry-After on 429. For ultra-high QPS, synchronize local in-memory counters to Redis asynchronously at small intervals, and fail open on Redis outage with alerting.
Follow-up Interview Question · How do you avoid a hot Redis shard when one tenant sends 50,000 requests/second?