API Rate Limiting Explained: Protecting Apps Without Blocking Real Users

Key Takeaways

Rate-limit the identity responsible for traffic, protect expensive endpoints first, allow normal bursts deliberately, return useful 429 responses, and monitor the policy after launch.

Aybars Altınyay
Aybars Altınyay
Platform Engineer & Technical Writer
Updated 17 min read
Written for: Developers and small backend teams designing API limits, quotas, throttling, concurrency, and abuse controls.
APIRate LimitingSecurityBackendReliabilityDevOps
Last reviewed:
Guide
API Rate Limiting Explained: Protecting Apps Without Blocking Real Users
rafftechnologies.com/learn

Host your API and its rate limits on your own server.

  1. 1Pick a Linux imageUbuntu, Debian and more, with your SSH key added.
  2. 2Choose a sizeFrom $4.99 a month. Resize when your app grows.
  3. 3Connect over SSHYour server is up in about 55 seconds.

Ubuntu, Debian and other Linux distributions with full root and SSH access, up and running in about 55 seconds.

API rate limiting controls how much request traffic a client, user, API key, tenant, IP address, or service can generate within a defined period. The goal is not simply to block traffic. Good rate limiting protects backend capacity, login flows, expensive endpoints, third-party dependencies, and fair access while giving legitimate clients a predictable way to recover when they reach a limit.

For Raff Technologies workloads, rate limiting is usually an application or reverse-proxy decision layered on top of the compute, network, security, and observability controls around the workload. The best policy depends on who owns the traffic, how expensive the endpoint is, whether the caller is authenticated, and whether rejected work could instead be queued or slowed down.

A useful rule is:

Rate-limit the identity that owns the traffic, protect expensive paths first, and make 429 responses actionable for legitimate clients.

API rate limiting: quick decision framework

API surfaceMain riskBetter limit keyTypical control
Public unauthenticated endpointBots, scraping, accidental burstsIP/source + routeConservative burst + sustained limits
LoginBrute force, credential stuffingAccount + source + routeTight throttling, progressive delay
Signup/password resetSpam and abuseAccount/email/sourceFrequency limits + abuse checks
Authenticated APITenant or integration overuseUser, tenant, API keyIdentity-aware quota
Expensive search/reportCPU/database pressureIdentity + endpointLower rate + concurrency limit
File uploadBandwidth, storage, processingUser/tenant + size + routeSize + frequency + concurrency
Webhook receiverRetry storms, burstsProvider/account/eventQueue + backpressure
Internal APIService overloadService identity + routeService-aware rate/concurrency limits
Admin actionHigh-impact misuseAdmin identity + actionConservative limits + audit evidence

Do not begin with “100 requests per minute for everything.” Begin with which resource or user experience needs protection.

What is API rate limiting?

API rate limiting is a policy that restricts request activity according to a key, quota, time window, concurrency level, cost unit, or combination of those controls.

Examples include:

  • 60 requests per minute per API key;
  • 5 login attempts per account in a short window;
  • 2 report-generation jobs running concurrently per tenant;
  • 100 uploads per day per workspace;
  • a short burst allowance followed by a lower sustained rate;
  • different limits for free and paid plans.

The limit key matters as much as the number. A limit applied to the wrong identity can block legitimate users while failing to constrain the actor causing pressure.

Why APIs need rate limits

Rate limiting protects more than security.

A production API may need protection from:

  • malicious scraping or brute force;
  • buggy clients retrying too aggressively;
  • batch jobs that accidentally loop;
  • one tenant consuming shared capacity;
  • expensive search/report endpoints;
  • file-processing spikes;
  • webhook retry storms;
  • external API or email-provider quotas;
  • sudden load on a database or queue;
  • plan or contract usage limits.

OWASP API Security identifies unrestricted resource consumption as an API risk because requests can consume compute, memory, storage, bandwidth, database capacity, and paid third-party services.

That makes rate limiting partly a reliability and cost-control mechanism, not just an abuse filter.

Rate limiting vs throttling vs quotas

These terms overlap but are useful to separate operationally.

ControlMain purpose
Rate limitRestrict request activity over time
ThrottlingSlow or reject traffic when policy/capacity is exceeded
QuotaControl a larger usage allowance, often per plan or billing period
Concurrency limitRestrict work executing at the same time
Queue/backpressureAbsorb valuable work and process it at a safe rate

A product can use several at once.

For example, an API may allow a short burst, enforce a per-minute request rate, cap daily usage, and permit only two heavy exports to run concurrently.

429 Too Many Requests: what it means

HTTP 429 Too Many Requests means the client has exceeded a rate policy and should reduce request activity. RFC 6585 defines the status code and allows the response to include Retry-After so the client knows when to retry.

A useful 429 response should help a legitimate developer recover.

Include, where appropriate:

  • a clear error code/message;
  • Retry-After or equivalent retry guidance;
  • the scope of the limit, such as user, token, tenant, or route;
  • safe quota information;
  • a request/correlation ID;
  • documentation for public APIs.

A minimal example:

Http
HTTP/1.1 429 Too Many Requests Retry-After: 30 Content-Type: application/json { "error": "rate_limit_exceeded", "retry_after_seconds": 30 }

Do not expose internal enforcement details that make abuse easier merely to make the error verbose.

Rate-limit headers are useful, but the standard is still evolving

Public APIs often expose quota information through provider-specific headers such as X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset.

The IETF HTTPAPI working group is also developing standardized RateLimit-Policy and RateLimit fields. As of May 2026, that work remains an Internet-Draft, not a finalized RFC, so treat it as work in progress rather than a settled standard.

The durable design principle is simpler: if customers depend on your API, give them enough information to avoid unnecessary throttling and implement backoff correctly.

Choose the right rate-limit key

The key identifies who or what is consuming the quota.

KeyGood fitMain limitation
IP addressUnauthenticated traffic and coarse abuse controlsNAT, VPNs, offices, mobile networks share IPs
User IDAuthenticated user fairnessOne user may act for a larger organization
Tenant/accountB2B SaaS fairnessLarge tenants may need higher policy limits
API keyIntegrations and automationShared keys reduce attribution
Route/actionProtecting expensive operationsUsually needs another identity dimension
Service identityInternal APIsRequires reliable service authentication
PlanContract or product quotaNot enough for burst protection

For authenticated APIs, user, tenant, API key, or organization is usually more meaningful than IP alone.

IP-based controls still help at the public edge, but they should not be the only fairness mechanism for logged-in users.

Do not use one global limit for every endpoint

Endpoints have different costs and risks.

A health check, login request, database search, export, upload, and billing action should not automatically share one policy.

Classify endpoints by:

  1. cost — CPU, database, storage, bandwidth, external API usage;
  2. security sensitivity — login, reset, admin, account changes;
  3. business impact — writes versus reads, destructive actions;
  4. expected burst behavior — UI page load, batch process, webhook;
  5. caller identity — anonymous, user, tenant, API client, internal service.

Then apply the narrowest policy that protects the actual bottleneck.

Burst limits and sustained limits solve different problems

Normal applications can create legitimate bursts.

A dashboard may load several resources at once. A mobile client may synchronize after reconnecting. A batch workflow may submit several related operations quickly.

A good policy often separates:

  • burst capacity for short legitimate spikes;
  • sustained rate for ongoing usage;
  • quota for longer-term allowance;
  • concurrency for expensive active work.

This is why token-bucket and similar designs are popular: they can allow controlled bursts while still limiting average throughput.

Rate limiting algorithms: fixed window, sliding window, token bucket, leaky bucket

The algorithm matters, but only after the policy is clear.

AlgorithmStrengthMain trade-off
Fixed windowSimple to implement and explainBoundary spikes near window reset
Sliding windowSmoother recent-time enforcementMore state/calculation
Token bucketAllows bursts while controlling average rateBucket size/refill need tuning
Leaky bucketSmooth output rateBursts may be delayed or rejected
Concurrency limiterProtects expensive in-flight workDoes not control total request volume

Fixed window

A counter resets on a fixed boundary such as each minute. It is easy to operate but can permit traffic spikes around the boundary.

Sliding window

The server evaluates activity across the most recent interval rather than a shared reset point. It gives smoother enforcement at higher implementation cost.

Token bucket

Tokens refill at a defined rate. Requests consume tokens. A larger bucket permits short bursts without allowing unlimited sustained traffic.

Leaky bucket

Work leaves the bucket at a controlled rate, which is useful when smoothing traffic matters more than allowing immediate bursts.

For most small teams, the best algorithm is the one that matches expected client behavior and can be observed and tuned reliably.

Rate limiting should protect expensive endpoints first

If implementation time is limited, prioritize endpoints where one request can trigger disproportionate work.

Start with:

  • login and password reset;
  • signup and verification;
  • expensive search;
  • reports and exports;
  • file uploads;
  • AI/compute-heavy operations;
  • external API calls;
  • email/SMS actions;
  • webhook receivers;
  • administrative writes.

A cheap cached read endpoint may tolerate much higher request rates than a report that performs several database joins and generates a file.

Rate limiting should work with queues and backpressure

Some valid work should be delayed rather than rejected.

Queues are useful for:

  • exports;
  • image/file processing;
  • webhook processing;
  • email delivery;
  • background reports;
  • batch jobs;
  • long-running tasks.

A useful pattern is:

Text
Request ↓ validate + authorize Accept job ↓ Queue ↓ controlled concurrency Workers ↓ Result / callback / status

Rate limits still matter because a queue can also be overwhelmed. The difference is that valuable work can be absorbed and processed safely instead of failing immediately.

Read Cron Jobs vs Queues vs Workflow Automation for the wider background-work decision.

Login rate limiting needs special treatment

Authentication endpoints are both security-sensitive and user-sensitive.

Avoid simplistic policies that permanently lock accounts after a small number of failures. Attackers can intentionally trigger those failures and create denial of service for real users.

A stronger design can combine:

  • account-aware throttling;
  • source/IP signals;
  • progressive delay;
  • device/session context where available;
  • temporary challenge or verification;
  • monitoring for distributed attempts;
  • clear recovery paths.

The exact policy depends on the authentication system, but the goal is to slow abuse without giving an attacker an easy way to lock legitimate users out.

API keys and rate limits should be designed together

API keys are useful rate-limit identities because they can map traffic to a known integration.

Prefer:

  • one key per integration/customer/environment where practical;
  • an owner for every key;
  • scoped permissions;
  • separate development and production keys;
  • rotation and revocation procedures;
  • usage monitoring by key.

A shared key across several applications makes both rate limiting and incident investigation harder.

Use API Keys for Automation for the credential-lifecycle side of the design.

Rate limiting is not DDoS protection

Rate limiting and DDoS protection can both support availability, but they solve different layers of the problem.

ControlPrimary job
FirewallRestrict ports, protocols, and network sources
DDoS protectionDetect/filter high-volume or hostile traffic patterns
WAF/application filteringInspect HTTP requests and web attack patterns
API rate limitingAllocate request capacity by endpoint and identity
Concurrency limitProtect active workers/dependencies
QuotaEnforce longer-term usage policy

Application-aware rate limiting knows things network-level controls often do not: user ID, tenant, API key, endpoint cost, plan, or business action.

Use Cloud Security Fundamentals and Cloud Firewall Best Practices for the surrounding security layers. For mitigation boundaries and attack response, see DDoS Protection for Small Teams.

Observe rate-limit behavior after launch

A rate limit should not be “set and forgotten.”

Track signals such as:

  • 429 responses by endpoint;
  • 429s by user/tenant/API key;
  • top limited clients;
  • request rate before and after limiting;
  • backend CPU/memory/database load;
  • queue depth;
  • retry behavior;
  • support tickets about throttling;
  • error rates after limit changes;
  • cost/resource trends on expensive endpoints.

Interpret the signals carefully.

If only known abusive clients hit limits, the control may be working as intended. If normal users repeatedly hit them, the limit may be too strict or the application may be generating unnecessary requests.

Read Observability for Small Teams for the monitoring layer.

API rate limiting best practices

A practical production baseline is:

  1. Define the resource being protected. CPU, database, login flow, third-party API, storage, or fair tenant capacity.
  2. Choose the responsible identity. IP, user, tenant, API key, service, or action.
  3. Protect high-cost endpoints first. Do not spend the same engineering effort on every route.
  4. Allow normal bursts deliberately. Avoid punishing legitimate page loads or synchronization.
  5. Use concurrency limits for expensive work. Request count alone may not protect active workers.
  6. Queue valuable asynchronous work. Rejecting every burst is not always the best UX.
  7. Return useful 429 responses. Include retry guidance where possible.
  8. Document public limits. Customers should not discover quotas only through production failures.
  9. Monitor limit hits. Rate policy needs evidence to improve.
  10. Review policy after traffic or architecture changes. New endpoints and larger customers can change the correct threshold.

How API rate limiting fits Raff

Rate limiting is generally implemented close to the application because the application knows the identity and business cost of each request.

A Raff-hosted API can apply controls at several layers:

Text
Client traffic ↓ Network/security controls ↓ Reverse proxy or gateway ↓ Application middleware ↓ Queue / workers / database

Raff VM and Linux VM can host reverse proxies, API services, containers, queues, caches, workers, and application-level limiters. Raff VPC can keep supporting services on private paths where appropriate, while Raff Security covers the current infrastructure security surface.

The important ownership boundary is that Raff provides the infrastructure layer; your application still decides which user, tenant, route, API key, or business action receives which rate policy.

For API endpoints deployed as functions, see Serverless API Security: Authentication, CORS & Rate Limiting. This describes application controls rather than an automatic rate-limiter included with the hosting platform.

Raff VMs include DDoS protection and unmetered bandwidth, from $4.99 a month (pricing).

Run your API on Raff VM or Linux VM and apply rate limits at the reverse-proxy, application, queue, or service layer that best understands your traffic.

14-day money-back guarantee

Deploy Your Server

API rate limiting checklist

Policy

  • The protected resource is clear.
  • Each high-risk endpoint has an owner.
  • Anonymous and authenticated traffic use appropriate keys.
  • Expensive endpoints have specific controls.

Client behavior

  • Normal bursts are supported deliberately.
  • 429 responses include useful retry guidance.
  • Public API limits are documented.
  • Client retry/backoff behavior is understood.

Backend protection

  • Database-heavy work has tighter controls.
  • Concurrency is limited where request count is insufficient.
  • Queues have backpressure and maximum growth controls.
  • Third-party dependencies cannot be flooded by one client.

Operations

  • 429s are measured by endpoint and identity.
  • Limit changes can be rolled back.
  • Support can identify why a legitimate client was limited.
  • Policies are reviewed after incidents and major traffic changes.

Frequently asked questions

What is API rate limiting?

API rate limiting controls how much request traffic a client, user, API key, tenant, IP address, or service can generate during a defined period or quota window.

What does 429 Too Many Requests mean?

HTTP 429 means the client exceeded a server-defined rate policy. A useful response should tell legitimate clients how to slow down or when to retry, commonly with Retry-After where appropriate.

What is the best rate limiting algorithm?

Token bucket is the most common choice because it allows short bursts while enforcing an average rate. Fixed window is the simplest, sliding window is smoother, and leaky bucket smooths request flow. Choose based on expected client behavior and operational needs.

What is the difference between token bucket and leaky bucket?

Token bucket accumulates capacity and can allow controlled bursts. Leaky bucket releases work at a steadier rate, making it useful when smoothing traffic is more important than immediate bursts.

Should API rate limits use IP address or API key?

Use IP-based controls for coarse anonymous traffic, but authenticated APIs usually benefit from user-, tenant-, service-, or API-key-based limits because they better represent responsibility.

Is API throttling the same as rate limiting?

The terms often overlap. Rate limiting defines the usage policy, while throttling usually describes slowing or rejecting traffic when that policy or capacity boundary is reached.

Is API rate limiting the same as DDoS protection?

No. DDoS protection addresses broader attack traffic, while API rate limiting allocates application request capacity by identity, endpoint, quota, or business cost.

Should every API endpoint have the same limit?

No. Endpoint cost and risk differ. Login, uploads, reports, search, webhooks, and cheap cached reads often need different rate or concurrency policies.

How do I avoid blocking real users with rate limits?

Use identity-aware keys, allow expected bursts, apply endpoint-specific limits, return clear 429 guidance, monitor legitimate limit hits, and queue valuable work when delay is better than rejection.

Should public APIs expose rate-limit headers?

Public APIs should provide enough quota and retry information for clients to behave correctly. Header conventions vary, and the IETF RateLimit header work remains an Internet-Draft as of 2026.

Conclusion

API rate limiting works best when it is treated as a product reliability control rather than a single security number.

Identify the expensive or sensitive resource, choose the identity responsible for the traffic, allow normal bursts intentionally, protect heavy work with concurrency or queues, return useful 429 responses, and monitor real behavior after launch.

The correct policy will change as your API, customers, and workload architecture evolve. Keep the enforcement understandable enough that your team can explain why a request was limited and adjust the rule without breaking legitimate users.

Sources

Was this article helpful?
Aybars Altınyay
Aybars Altınyay
Platform Engineer & Technical Writer

Aybars is a Platform Engineer & Technical Writer at Raff Technologies. He works on Linux VM templates, self-hosted application workflows, and security-focused deployment validation, turning tested infrastructure procedures into clear, practical tutorials for developers and teams.

Host your API and its rate limits on your own server.

Ubuntu, Debian and other Linux distributions with full root and SSH access, up and running in about 55 seconds.

14-day money-back guarantee

Frequently asked questions

What is API rate limiting?
API rate limiting controls how much request traffic a client, user, API key, tenant, IP address, or service can generate during a defined period or quota window.
What does 429 Too Many Requests mean?
HTTP 429 means the client exceeded a server-defined rate policy. A useful response should tell legitimate clients how to slow down or when to retry.
What is the best rate limiting algorithm?
Token bucket is the most common choice because it allows short bursts while enforcing an average rate. Fixed window is the simplest, sliding window is smoother, and leaky bucket smooths request flow.
What is the difference between token bucket and leaky bucket?
Token bucket accumulates capacity and can allow controlled bursts. Leaky bucket releases work at a steadier rate.
Should API rate limits use IP address or API key?
Use IP-based controls for coarse anonymous traffic, but authenticated APIs usually benefit from user-, tenant-, service-, or API-key-based limits.
Is API throttling the same as rate limiting?
The terms often overlap. Rate limiting defines the usage policy, while throttling usually describes slowing or rejecting traffic when the boundary is reached.
Is API rate limiting the same as DDoS protection?
No. DDoS protection addresses broader attack traffic, while API rate limiting allocates application request capacity by identity, endpoint, quota, or business cost.
Should every API endpoint have the same limit?
No. Login, uploads, reports, search, webhooks, and cheap cached reads often need different rate or concurrency policies.
How do I avoid blocking real users with rate limits?
Use identity-aware keys, allow expected bursts, apply endpoint-specific limits, return clear 429 guidance, monitor legitimate limit hits, and queue valuable work when delay is better than rejection.
Should public APIs expose rate-limit headers?
Public APIs should provide enough quota and retry information for clients to behave correctly. Header conventions vary, and the IETF RateLimit header work remains an Internet-Draft as of 2026.