Course contentsShow
← System Design
Lesson 958 of 1,91925. Rate Limiting and ThrottlingFree lesson

Rate Limit Scopes

Identify what to rate limit: per user, per IP, per API key, per endpoint, or combinations thereof.

Rate Limit Scopes

What you'll learn: How to define which entity or dimension you'll measure and enforce rate limits against in your system.

Understanding Rate Limit Scopes

When implementing rate limiting, you must decide what to count. A "scope" is the boundary that defines which requests get grouped together for rate limit calculations. Think of it like choosing whether to count cars per driver, per license plate, per parking lot entrance, or some combination—each scope serves different protection goals.

Common Rate Limit Scopes

Per User

Tracks limits based on authenticated user identity. Prevents individual accounts from overwhelming your system, regardless of how many devices they use.

Per IP Address

Counts requests from the same IP address. Useful for catching abuse from unauthenticated endpoints or blocking attackers, but can accidentally penalize users behind shared corporate NATs or VPNs.

Per API Key

Enforces quotas on third-party integrations. Different customers might have different tier limits (free vs premium).

Per Endpoint

Sets different thresholds for different operations. A computationally expensive report generation endpoint might allow 10 requests/minute, while a simple read might allow 1000.

Combination Scopes

Real systems often layer multiple scopes: "100 requests per minute per user" AND "10,000 requests per minute per endpoint globally." This provides defense in depth—protecting both individual fairness and system-wide capacity.

Choosing Your Scope

Your choice depends on what you're protecting against. User scopes prevent individual abuse, IP scopes catch anonymous attacks, endpoint scopes prevent expensive operations from crushing your backend, and API key scopes enable business models with tiered access.

Key Takeaway: Rate limit scopes define the grouping dimension (user, IP, API key, endpoint, or combinations) that determines which requests count toward a shared limit—choose scopes that match your protection and fairness goals.