Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Complexity-Based Rate Limiting
Cyber Security

Complexity-Based Rate Limiting

← Back to Glossary
By NHI Mgmt Group Updated November 18, 2026 Domain: Cyber Security

Complexity-based rate limiting is an API control that limits requests by estimated execution cost rather than simple request count. It measures factors such as field depth, nesting, and resolver expense, which helps stop a few highly complex queries from consuming disproportionate server resources.

How Complexity-Based Rate Limiting Works

Complexity-based rate limiting is an API defense that goes beyond simple request counts. Instead of treating every call as equally expensive, it estimates how much work a request will force the server to do, then throttles based on that cost. That makes it better suited to APIs where a small number of expensive queries can create outsized load.

The core idea is fairness by work, not fairness by count. A shallow lookup and a deeply nested query may both be “one request,” but they can consume very different amounts of CPU, memory, database time, and resolver execution. Complexity scoring helps expose that difference before the request is fully processed.

This approach is especially relevant to APIs that support flexible query shapes, such as GraphQL, or any endpoint where the caller can influence nesting, fan-out, pagination depth, filter breadth, or server-side expansion. It is less about volume alone and more about preventing expensive shapes from becoming a bypass around ordinary throttles.

Why Query Cost Matters More Than Request Count

Count-based limits are easy to understand, but they can miss low-and-slow abuse patterns and legitimate-looking requests that are computationally heavy. If one request can trigger many resolver calls, joins, backend lookups, or downstream service invocations, then an attacker or buggy client can consume disproportionate resources without tripping a naive rate limit.

Complexity-based controls are designed to protect shared capacity and preserve service quality. They reduce the chance that one tenant, integration, or automated client can monopolise the API tier, exhaust worker pools, or create latency spikes that affect other users.

For GraphQL-style APIs, this often means combining query depth, field multiplication, aliasing, resolver cost, and pagination rules into a single cost model. For other APIs, it may mean scoring expensive filters, expansion parameters, batch sizes, or nested include paths rather than only counting calls per minute.

NHIMG’s Rate Limiting and API Abuse Guide covers the practical design patterns behind quotas, 429 handling, bypasses, and adaptive throttling, which are the natural operational companions to cost-based enforcement.

Common Failure Modes and Bypass Paths

A cost-based limiter can fail if the score underestimates real execution cost, especially when business logic, database access, or resolver chaining is more expensive than the first-pass estimate suggests. It can also be bypassed when attackers split one expensive action into many smaller-looking requests, vary query structure to evade signatures, or exploit gaps between gateway-level rules and application-level execution.

Another risk is false confidence from incomplete coverage. If only one route, schema, or operation type is scored, then uncapped paths can become the easiest abuse channel. The same problem appears when the limiter protects the edge but not downstream fan-out, because the API may still trigger heavy backend work after the request has been admitted.

In practice, the control should be treated as part of a broader resource-protection stack that includes timeouts, concurrency caps, schema validation, pagination discipline, and observability. The most useful metric is not just how many requests were blocked, but whether the API stays stable under adversarially shaped traffic.

Where It Fits in API Protection

Complexity-based rate limiting is strongest when it complements authentication, authorisation, and gateway controls rather than replacing them. It helps stop resource abuse, but it does not decide whether a caller should be allowed to see a particular object or execute a particular action. That is why it is often paired with schema enforcement, per-operation policy, and strict backend authorisation checks.

For APIs that expose rich query languages or expensive backend aggregation, the control becomes a practical way to convert design intent into enforcement. It lets teams express that some operations are allowed, but only at a sustainable cost, which is often the difference between a resilient API and one that can be destabilised by a few cleverly shaped requests.

REST vs GraphQL Security explains why GraphQL query cost, depth, aliasing, and resolver authorisation need more careful treatment than ordinary endpoint counting, while WAF vs API Gateway shows where edge enforcement ends and API-native controls begin.

Risk and Threat Considerations

Complexity-based rate limiting exists because attackers, automation, and even accidental misuse can turn a small number of requests into a disproportionate resource drain. The main risk is not just traffic volume, but request shape: expensive queries can drive CPU, memory, backend fan-out, and latency far beyond what a simple requests-per-minute limit would reveal.

Failure mechanism: The limiter misjudges execution cost, misses an expensive path, or allows repeated high-complexity requests to reach the application and overload shared resources.

Impact: The API can suffer slowdown, queue buildup, degraded availability, or a denial-of-service condition, especially when the expensive requests also trigger costly downstream calls or database work.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP API Security Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP API Security Top 10API4 — Unrestricted Resource ConsumptionComplexity-based limits directly address API requests that consume excessive resources.
API6 — Unrestricted Access to Sensitive Business FlowsCost-based throttling helps constrain automation against expensive high-value API flows.
Recommendation — Score request cost and cap high-expense operations before they exhaust shared API resources. Apply operation-specific limits to keep sensitive flows from being abused at scale.
NIST SP 800-53 Rev 5SC-5 — Denial of Service ProtectionThe control is a resource-protection measure intended to limit service exhaustion.
AC-10 — Concurrent Session ControlConcurrency-style limits help bound simultaneous expensive activity and preserve service capacity.
AU-2 — Event LoggingVisibility into expensive requests is needed to tune and verify cost-based throttling.
Recommendation — Enforce rate and workload controls that reduce denial-of-service exposure on API services. Cap concurrent high-cost activity so one client cannot monopolize capacity. Log request complexity signals and outcomes to tune thresholds and spot abuse.

Practitioner Guidance

Why practitioners should care: Treat complexity scoring as an engineering control, not a policy slogan. If the score does not track real backend cost, the limiter will either block too much or protect too little, and both outcomes create operational friction.

What to watch for: Validate the limiter against representative production traffic and deliberately expensive query shapes, then compare the score to actual execution time, backend load, and error rates. If the control protects only the edge but not the expensive parts of the request path, tighten the model before expanding usage.

Practitioner takeaway: The best implementations make “expensive but legitimate” traffic predictable and bounded, rather than trying to eliminate all complexity outright.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 18, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org