Search docs…⌘K
Dashboard →
Guides

Global Rate Limiting

How to design rate limits for multi-tenant SaaS applications and protect your upstream services globally across all Relay Edge POPs.

Tiered Limits (Free vs Pro)

When building a multi-tenant SaaS, you often need different rate limits depending on the customer's subscription tier. For example, Free users might be limited to 100 requests per minute, while Pro users can make up to 1,000 requests per minute.

Relay allows you to define multiple rate limit profiles (e.g., Free, Pro, Enterprise) and dynamically apply them based on the API Key being used.

Mapping API Keys to Profiles

Instead of hardcoding limits into your backend application, you can map each API Key to a specific rate limit profile in Relay. When a client makes a request, Relay inspects the token, identifies the associated profile, and enforces the corresponding limit before traffic ever reaches your backend.

  • Free tier: 100 req / minute
  • Pro tier: 1,000 req / minute
  • Enterprise tier: 10,000 req / minute

Global Edge Enforcement

Relay operates a globally distributed edge network. When you configure a rate limit, it applies globally across all Relay Edge POPs (Points of Presence). This means if a user makes 50 requests in Tokyo and 50 requests in New York, they will hit a 100-request global limit instantly, ensuring your upstream services are protected from distributed abuse.

Rate Limit Headers

To help developers understand their current usage, Relay automatically injects standard rate limit headers into every HTTP response returned to the client:

  • x-relay-limit-limit: The maximum number of requests permitted in the current time window.
  • x-relay-limit-remaining: The number of requests remaining in the current window.
  • x-relay-limit-reset: The Unix timestamp when the current window expires and limits are reset.