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

Per-User vs Per-IP Rate Limiting

Comparing rate limiting by authenticated user versus IP address, their use cases, and security tradeoffs.

Per-User vs Per-IP Rate Limiting

What you'll learn: How to choose between rate limiting by authenticated user identity versus IP address, and understand the security tradeoffs of each approach.

Two Ways to Identify "Who"

When enforcing rate limits, you need to identify the requester. The two most common identifiers are:

  • Per-User: Rate limit based on authenticated user credentials (user ID, API key, OAuth token)
  • Per-IP: Rate limit based on the client's source IP address

Per-User Rate Limiting

Use cases:

  • API services with authenticated users
  • Enforcing tier-based quotas (free vs premium users)
  • Protecting against individual account abuse

Advantages:

  • Precise tracking per account
  • Fair allocation across users behind NAT/proxies
  • Supports tiered service levels

Drawbacks:

  • Requires authentication (can't protect login endpoints)
  • User can create multiple accounts to bypass limits

Per-IP Rate Limiting

Use cases:

  • Public endpoints (login, signup, password reset)
  • Protection against DDoS attacks
  • Unauthenticated API endpoints

Advantages:

  • Works without authentication
  • Simple to implement
  • Protects infrastructure-level resources

Drawbacks:

  • Unfair to users behind shared IPs (corporate NAT, mobile carriers)
  • Can be bypassed with VPNs or IP rotation
  • May block legitimate traffic from large networks

Choosing the Right Approach

Often, use both together: per-IP for unauthenticated endpoints and coarse protection, per-user for authenticated fine-grained control. For example, rate limit login attempts by IP (prevent brute force), but rate limit API calls by authenticated user ID (enforce quota tiers).

Key Takeaway: Per-user rate limiting provides precise, fair quotas for authenticated traffic, while per-IP protects unauthenticated endpoints and infrastructure — combining both offers defense-in-depth against abuse.