Rate Limiting and API Quotas for Business Applications
In this article
- Rate limiting and quotas are not the same thing
- Why you need it before problems appear
- Deciding who gets counted
- Commonly used algorithms
- Cost-based limits, not just counts
- Where to place the limiter
- Responses that help the caller
- Client behaviour: backoff and idempotency
- Protecting sensitive endpoints
- Quotas and service plans
- Monitoring and tuning
- Testing the limiter
- A four-week plan
- Documentation for partner developers
- Conclusion
Every business application that opens an API, whether for a mobile app, integration partners, or AI agents, sooner or later meets a caller that asks for too much. Sometimes the cause is not malicious: a partner script that loops endlessly because of a configuration error, or a customer who presses the sync button many times. At other times someone deliberately guesses passwords or drains all the data. Without limits, one caller can use up capacity and slow down every other customer. This article covers rate limiting and quotas: how they differ, how to design them, and how to communicate them to API users.

Rate limiting and quotas are not the same thing
The two terms are often swapped, yet their purposes differ.
- A rate limit restricts speed: how many requests per second or minute. Its purpose is to protect system stability from spikes and abuse.
- A quota restricts the total in a given period, for example 100,000 requests per month or 5,000 documents per day. Its purpose is to control cost and enforce service plans.
- A concurrency limit restricts how many requests one caller may have processed at the same time, useful for heavy operations such as report exports.
A mature application usually uses all three. The rate limit protects the server this minute, the quota protects the budget and business model this month, and the concurrency limit protects expensive operations.
Why you need it before problems appear
Adding limits after an incident is much harder, because users are used to unlimited behaviour and sudden restrictions break their integrations. There are several reasons to add them from the start.
- Isolation: one customer must not degrade service for others.
- Security: repeated login attempts, OTP guessing, and mass data extraction can be slowed or stopped. Other security basics are covered in [basic security for business applications](/blog/keamanan-dasar-aplikasi-bisnis).
- Cost: calls to paid services behind the API, such as AI models, SMS sending, or identity verification, mean every request has a price.
- Predictability: clear limits help capacity planning, especially before busy seasons as in [readiness for year-end promotion traffic spikes](/blog/kesiapan-lonjakan-trafik-promo-akhir-tahun-uji-beban-dan-kapasitas).
- Commercial clarity: quotas per plan become the basis of pricing, as discussed in [usage-based billing](/blog/penagihan-berbasis-pemakaian-metering-dan-rating-untuk-produk-saas-dan-jasa-digital).
Deciding who gets counted
A limiter needs an identifying key: who is being limited. The choice of key determines fairness and how easy it is to evade.
- Per IP address: easy, but it penalises many users behind one office network and attackers can evade it with many addresses.
- Per API key or token: the fairest for authenticated callers, and the basis for plan quotas.
- Per user: useful for applications serving many users through one integration key.
- Per tenant or organisation: important in multi-customer applications so one organisation does not exhaust the shared allowance.
- Per endpoint: login and password reset get stricter limits than reading a product list.
- Combinations: for example a global limit per key plus a specific limit per endpoint.
For unauthenticated endpoints such as login, combine the IP address with the identity being tried (for example the username), so an attacker cannot guess one account from hundreds of addresses without being slowed.
Commonly used algorithms
Fixed window
Count requests in blocks of time, for example 100 requests per minute reset at second zero. Simple, but a caller can send 100 requests at the end of one minute and 100 more at the start of the next, so a double spike can get through.
Sliding window
Counts requests over the most recent time span that keeps moving. Smoother and fairer, with slightly higher storage needs.
Token bucket
A bucket of tokens refilled at a steady rate; each request takes one token. A full bucket allows short bursts while the average rate stays controlled. Suitable for APIs that reasonably accept small spikes.
Leaky bucket
Requests enter a queue and are processed at a constant rate. Useful for smoothing load into downstream systems that cannot tolerate spikes.
None is always best. Token bucket and sliding window are usually good first choices for most business applications.
Cost-based limits, not just counts
Not all requests weigh the same. Reading one product is much lighter than exporting ten thousand rows or running an AI analysis. Where possible, assign weights: a light read is worth 1, a large list 5, an export 50. The limiter then counts total weight, not the number of requests. This is fairer and deters abuse of expensive endpoints.
For AI features, add a limit on tokens or number of calls per user per day, plus budget alerts. A single agent trapped in an endless loop can burn through a budget overnight; see also identity and access rights for AI agents in business applications.
Where to place the limiter
Limiters can sit at several layers, and are often combined.
- Network edge or CDN: filters bad traffic before it touches the server, suited to coarse protection per IP address.
- API gateway: enforces limits per key and per plan centrally.
- Application: understands business context, for example limits per tenant or per feature.
- Database and downstream services: connection pools and concurrency limits as a last safeguard.
If you run more than one server, counters must be shared, usually in fast storage such as Redis, so limits do not multiply by the number of servers. Also design behaviour for when the counter storage fails: are requests still allowed (fail open) or rejected (fail closed)? For login, fail closed is safer; for reading a catalogue, fail open is friendlier to customers.
Responses that help the caller
A good limiter tells the caller what happened, so reasonable integrations can adapt.
- Return status code 429 (Too Many Requests) when the limit is reached, not 500 or 403.
- Include a Retry-After header stating how many seconds to wait.
- Include remaining allowance and reset time, for example via the RateLimit headers now being standardised, or consistent custom headers.
- Give a clear error message in the body, including the applicable limit and a link to documentation.
- Log every rejection with the caller's key for analysis.
Do not drop connections without explanation or leave requests hanging; callers will retry more aggressively and make things worse.
Client behaviour: backoff and idempotency
The limiter is only half of the equation. Clients must behave well too.
- Use exponential backoff with random jitter on receiving 429 or 503, so thousands of clients do not retry in the same second.
- Respect Retry-After when present.
- Cap the number of retries and never retry without limit.
- Use idempotency keys on operations that change data, so retries do not create duplicate orders or payments.
- For bulk synchronisation, use batch operations or queues, not thousands of single requests. This pattern is covered in [event-driven architecture and message queues](/blog/arsitektur-event-driven-dan-antrean-pesan-untuk-aplikasi-bisnis).
Webhook receivers need similar protection; see webhooks and real-time integration for business.
Protecting sensitive endpoints
Some endpoints need stricter rules than the general limit.
- Login: limit attempts per account and per address, add increasing delays, and consider extra verification after several failures. Passwordless methods reduce the attack surface; see [passkeys and passwordless login](/blog/passkey-dan-login-tanpa-kata-sandi-untuk-bisnis).
- OTP or reset link requests: limit sends per number or email, because every send costs money and can be abused to flood other people.
- Search and customer data lists: limit to prevent mass data extraction.
- Public forms: add limits and anti-bot challenges that do not harm legitimate users.
Quotas and service plans
If your API is sold or used by partners, quotas become part of the product.
- Define plans clearly: per-minute limits, monthly quotas, and behaviour when exhausted (rejected, slowed, or overage billed).
- Show usage in the customer dashboard so there are no surprises, and send alerts at 80 percent and 100 percent of quota.
- Provide a path for plan upgrades or temporary exceptions for special events.
- Record usage accurately because it is the basis of billing; discrepancies here turn directly into disputes.
Monitoring and tuning
Limits set once and forgotten become too loose or too tight. Monitor:
- The number and percentage of rejected requests per key and per endpoint.
- Keys that often approach the limit, as candidates for plan upgrades or technical discussion.
- Sudden spikes in rejections, which can mean an attack or a client bug.
- The effect on overall response time and error rate.
Connect this with practices in observability, logs, and error handling. Start with loose limits in observation mode (log without rejecting), learn real patterns over a few weeks, then enforce.
Testing the limiter
- Test that limits are enforced at the promised figures and headers show correct values.
- Test that one key exceeding its limit does not affect other keys.
- Test behaviour when the counter storage is unavailable.
- Test your reference client with backoff and retries.
- Include these scenarios in load tests and the release checklist.
A four-week plan
- Week one: inventory endpoints and callers, group them by risk and cost, and decide the limiter keys.
- Week two: install the limiter in observation mode, add response headers, and update API documentation.
- Week three: enforce limits on sensitive endpoints such as login and OTP, and notify affected partners and customers.
- Week four: enforce general limits and quotas, enable alerts, and schedule monthly reviews.
Documentation for partner developers
Limits that are not documented feel like random errors. Write the limit figures per plan, how to read the headers, sample 429 responses, and backoff recommendations into the API documentation. Announce limit changes well in advance through email and release notes, and provide a sandbox with limits that mimic production so partners can test their integrations.
Conclusion
Good rate limiting is not a wall but a fair flow regulator. It protects the system from spikes and abuse, keeps costs under control, and gives users clear rules. Start with the most sensitive and most expensive endpoints, communicate limits through headers and documentation, and keep monitoring so the limits stay relevant as your business grows.
Need an API that is secure, stable, and ready to grow?
AG·SORA designs and builds APIs with rate limiting, quotas, monitoring, and clear documentation for your business applications.
Free consultationRecommended for you
Reading related to this topic
Windows Server 2016 End of Support: Migration Planning
Windows Server 2016 support ends January 2027. Inventory, upgrade, migration, cloud, ESU, interim safeguards, priorities, testing, and a six-week plan.
PHP 8.2 End of Life: Upgrade Planning for Business Applications
PHP 8.2 support ends 31 December 2026. PHP and Node.js dates, inventory, risk priority, target versions, tests, staged upgrades, release, rollback, and CMS plugins.
Post-Quantum Cryptography for Business: Inventory and Crypto-Agility
Realistic post-quantum preparation: NIST standards and timelines, long-lived data risk, cryptographic inventory, priorities, crypto-agility, vendor questions, testing, and a roadmap.
Free checklist: choosing a software house
24 points to evaluate a vendor before you sign. Can be saved as a PDF.
Ready to build a system that grows with your business?
Discuss your needs with the AG·SORA team, no cost, no commitment.