TECH Nov 30, 2026 · by Skills Team

API Rate Limiting and Quotas: Protecting Shared Services

API rate limiting and quotas keep shared services fast and fair. Learn token bucket, sliding window, 429 handling, and gateway enforcement.

API Rate Limiting and Quotas: Protecting Shared Services

Key Takeaways

  • API rate limiting best practices cap requests per client so one heavy caller cannot slow the service for everyone.
  • Pair short-term rate limits with longer-term quotas to control both sudden bursts and steady overuse.
  • Use a token bucket for burst-friendly public APIs and a sliding window counter for strict, fair limits.
  • Return 429 with Retry-After and standard limit headers so clients can back off instead of retrying blindly.

API rate limiting best practices protect a shared service by capping how many requests each client can make in a set time window and rejecting the excess with a clear 429 response. A quota sets the longer-term allowance, such as requests per day, while a rate limit controls short bursts, such as requests per minute. Together they keep one heavy client, one faulty integration, or one automated agent from slowing the service for everyone else. This matters more in 2026 than ever, because AI agents now generate large volumes of API traffic, and a single agent task can fan out into dozens of parallel calls. This article explains the main algorithms, fair quotas, 429 handling, gateway enforcement, observability, and the mistakes that weaken most limiters.

What Is API Rate Limiting?

API rate limiting is a control that caps how many requests a client can send to an API within a defined time window and rejects the excess once the cap is reached. A quota is a longer-term allowance, often measured per day or per month, that bounds total use over a longer period. The rate limit stops sudden floods, while the quota stops slow, steady overuse. Limits are usually keyed to an API key, a user account, a tenant, an IP address, or a single endpoint.

The need for limits is easy to see in the threat data. According to Akamai, average daily API attacks per enterprise rose from 121 in 2024 to 258 in 2025, a 113 percent increase. According to Salt Labs, 99 percent of organizations encountered API security issues in the past 12 months. Honest clients cause overload too: a retry loop with no backoff can multiply one failed request into hundreds. Perplexity launched Multiagent on November 17, 2026, letting one lead agent coordinate up to 16 subagents in parallel, which shows how quickly one user request can turn into a burst of coordinated API calls.

How Do API Rate Limiting Best Practices Protect Shared Services?

API rate limiting best practices protect shared services by enforcing limits in layers, so abuse is stopped as early as possible in the request path. The first layer sits at the edge, in the gateway or load balancer, and rejects obvious floods before they reach application servers. The second layer sits in the application, where limits can depend on things only the application knows, such as the tenant, the operation, or the resource being touched. A third layer can sit on a single heavy endpoint, such as search or export, where one call consumes far more work than a simple read.

Layered limits also make fairness possible. Per-tenant limits give each tenant a defined share, per-key limits stop one leaked or misused key from spending the whole tenant share, and per-endpoint limits protect the heavy operations that a flat limit would leave exposed. When one tenant hits a limit, only that tenant sees 429 responses, and every other tenant keeps working normally. Teams building or extending an API should treat limiting as part of the design, and the API development and integration services from Skills Technology Solutions cover gateway setup, quota design, and endpoint protection.

Which Algorithm Should You Choose?

Five algorithms cover almost every production case, and the table below compares them at a glance.

AlgorithmBurst handlingAccuracyBest use
Fixed windowUp to double the limit at edgesRough near boundariesInternal or low-risk limits
Sliding window logNo bursts beyond the limitExactLow-volume, strict limits
Sliding window counterSmoothed burstsClose approximationGeneral-purpose default at scale
Token bucketAllows bursts up to bucket sizeExact average ratePublic multi-tenant APIs
Leaky bucketNo bursts, steady outputExact output rateSystems that cannot handle spiky traffic

A token bucket is a container that refills with tokens at a steady rate up to a fixed capacity, where each request spends one token and an empty bucket means the request is rejected. Token buckets are the industry default for public APIs because they absorb legitimate bursts while still capping the long-run average. Stripe sets token bucket capacity at five times the refill rate, so a client limited to 100 requests per second can burst to 500, according to the HLD Handbook.

A sliding window counter is a limiter that blends the counts of the current and previous fixed windows, weighted by how much of the previous window still overlaps the rolling window. It keeps only two counters per key. Data from Cloudflare, reported in the HLD Handbook, shows that a sliding window counter measured across 400 million requests and 270,000 distinct sources recorded a 0.003 percent error rate with zero false positives. A fixed window is simpler but has a known flaw: a client can send the full allowance at the end of one window and again at the start of the next, doubling the intended rate, and Figma rejected the fixed window for exactly this boundary flaw, according to the HLD Handbook. Most teams use a hybrid: a token bucket per key, a sliding window counter on strict endpoints, and a concurrency limit on heavy operations.

What Are API Rate Limiting Best Practices for Quotas?

API rate limiting best practices for quotas start with separating the short-term rate from the long-term allowance. The rate limit, measured in seconds or minutes, protects the system from floods and retry storms. The quota, measured in hours or days, protects the shared capacity from steady overuse and gives each tenant a predictable share. Both controls must be present, because a client under the rate limit can still exhaust a daily quota. Quotas should also be set per tenant and per endpoint, because a cached read and a full-text search do not consume the same work. A practical approach is to assign each operation a weight, such as one token for a read and ten for a search or an export.

Quotas must be visible to the client. Every response should carry standard limit headers, such as RateLimit-Limit, RateLimit-Remaining, and RateLimit-Reset, so a client can see its allowance, its remaining balance, and the time the window resets. The IETF published a draft standard for these headers in May 2026, and following it means clients built for one API can read the limits of another without custom parsing. Teams should also warn clients as they approach a quota, document every limit, and announce any change well before it takes effect. Agent traffic deserves its own quota thinking, since AI agents issue many more calls per user task than a human clicking through a dashboard. The agentic commerce readiness guide explains how AI buyers now transact through agents, which means APIs that serve agents need quotas sized for agent-shaped traffic, with separate allowances for agent sessions.

How Should Clients Handle 429 Responses?

A client that receives a 429 response should stop, read the Retry-After header, wait for the stated time, and then retry once, instead of retrying at once. The 429 status code is defined by RFC 6585 as Too Many Requests, and the Retry-After header is defined by RFC 9110, so a well-behaved client treats the pair as an instruction from the server. A server that returns 429 without Retry-After leaves the client guessing, and guessing clients retry too soon.

The standard retry pattern is exponential backoff with jitter. The client waits a short interval after the first 429, doubles the wait after each further 429, and adds a random jitter so that many clients waiting at once do not all retry in the same second. A sensible ceiling caps the total wait and retries, after which the client should surface the failure or queue the work for later. Operations that change state, such as creating an order, should also carry an idempotency key so a retried request is not applied twice. Good clients also protect themselves before the server has to, with a client-side cap on requests per minute and a circuit breaker that pauses calls when 429 responses cluster together.

Gateway Enforcement and Observability

Limits belong as close to the edge as possible. An API gateway, load balancer, or content delivery network can reject excess traffic before it touches application servers or databases, which is exactly where abuse should be stopped. Enforcement at the edge also keeps the limiter consistent across every instance, because a limit stored on one server is invisible to the others. A shared store such as Redis, updated atomically with a Lua script, gives every instance the same count and prevents race conditions. The application layer still has a role for limits that depend on the tenant or the operation weight. The cleanest design is a coarse limit at the gateway and a fine-grained limit in the application, with both layers returning the same 429 format and headers.

Observability turns a limiter from a silent wall into a diagnostic tool. Every rejected request should be logged with the key, the tenant, the endpoint, and the rule that fired, and dashboards should show rejected requests per key. Alerts should fire when a single key suddenly spikes or when legitimate tenants begin receiving 429 responses at an unusual rate, because each pattern means something different. The AI agent observability guide covers logs, traces, and alerts for agent traffic, and the same discipline applies to rate limiting: without per-key visibility, a team cannot tell a genuine attack from a misconfigured client or a tenant that has outgrown its allowance.

What Are the Common Mistakes in API Rate Limiting?

The most common mistake is relying on a single global limit for the whole API. A global limit protects the platform but not the tenants, because one heavy caller can spend the shared allowance and leave every other tenant locked out. Per-key, per-tenant, and per-endpoint limits must sit underneath the global ceiling so that one caller is contained before it can affect the rest. A related mistake is limiting by IP address alone: many users share one outbound IP through a corporate network or a mobile carrier, so a per-IP limit can block hundreds of innocent users.

Teams also weaken their limits by never testing them. A limiter that has never been load-tested may fail open under pressure, may count inconsistently across instances, or may admit twice the intended rate at window boundaries. A simple load test that drives a single key past its limit and checks the 429 will catch most of these flaws before a real incident does. A further mistake is enforcing limits only inside application code, where excess traffic has already consumed a connection before it is rejected. Finally, limits should never change silently: a limit lowered without notice breaks integrations that were working the day before.

Frequently Asked Questions

What is the difference between API rate limiting and quotas?

API rate limiting caps how many requests a client can send in a short window, such as per minute, to stop sudden floods and retry storms. A quota caps total use over a longer window, such as per day. Most shared services need both controls working together.

Which rate limiting algorithm is best for a public API?

A token bucket is the usual default for a public API because it allows short legitimate bursts while capping the long-run average. A sliding window counter suits strict endpoints such as login. Many teams combine both, with a token bucket per key and a sliding window on sensitive endpoints.

What should an API return when a client exceeds the limit?

An API should return HTTP 429 Too Many Requests with a Retry-After header stating when to retry, plus standard headers showing the limit, the remaining balance, and the reset time. The body should name the rule that fired so the client can adapt.

How many requests per minute should an API allow?

The right allowance depends on the endpoint, the typical client pattern, and the backend capacity behind it, so no single number fits every API. Start from observed peak usage plus headroom, weight heavy operations more than light reads, and review the numbers regularly.

Can rate limiting stop DDoS attacks on APIs?

Rate limiting reduces the impact of DDoS attacks on APIs by shedding excess traffic early, but it is one layer among several. It works best alongside gateway enforcement, bot detection, and authentication checks, with per-key and per-endpoint limits catching patterns that a single global limit would miss.

Well-chosen limits keep a shared service fast and fair for every tenant, even as AI agents multiply the traffic behind each request. Skills Technology Solutions, a software agency based in Rahim Yar Khan, Pakistan, serving clients in Pakistan and the UK, can help you put this into practice. Contact our team to discuss your project.

#API rate limiting#API quotas#API gateway#API security#429 handling