← InfraDraft

Infrastructure Primitives

Design a Rate Limiter

Enforce per-client request quotas across a distributed fleet without a shared bottleneck, using an algorithm suited to the burst tolerance you need.

Open and Simulate this Architecture in InfraDraft

Core Architectural Components

Token Bucket / Sliding Window Counter

The core limiting algorithm deciding allow vs. reject per request.

Distributed Rate-Limit Store

Redis (or similar) holding shared counters, updated atomically via INCR/EXPIRE or a Lua script.

Client Identification Layer

Resolves the limiting key — API key, IP address, or authenticated user ID.

Rule Configuration Service

Per-tenant and per-tier limit definitions, editable without a redeploy.

Edge Enforcement Gateway

API Gateway or reverse-proxy filter that rejects over-limit requests before they reach backend services.

Rejected-Request Response Handler

Returns 429 with Retry-After headers so well-behaved clients back off correctly.

Rate-Limit Metrics & Alerting

Tracks rejection rates per client/route to catch misconfigured limits or abuse.