---
title: "Cap each customer's running and queued · Agent Wranglers"
url: https://agentwranglers.se/playbook/scaling/exports-and-fair-share/per-tenant-limits
id: SCL-31
level: Recommended
applies: accounts
updated: 2026-10-27
build: a2a6bdfed830
tokens: 995
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Cap each customer's running and queued jobs

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Exports and fair share](https://agentwranglers.se/playbook/scaling/exports-and-fair-share.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: SCL-31
- Level: Recommended
- Chapter: [Exports and fair share](https://agentwranglers.se/playbook/scaling/exports-and-fair-share.md)
- Rule: Cap how much work each customer or tenant can have running or queued at once. One heavy customer then slows only their own work.
- Check: On staging, one tenant starts 100 exports at once. No more than its cap run together, and an export from another tenant starts within 30 seconds.
- Applies when: The project has user accounts.
- How: Per-client [rate limits](https://agentwranglers.se/playbook/application-security/limits-and-business-logic/rate-limits.md) count requests, but one export can cost more than a thousand page views. Count running work per tenant, such as jobs and open exports, in a shared store. Beyond the cap, queue the work or answer 429. The Google SRE book sets quotas per customer, and under overload it refuses only the customers over their quota. Larger plans can get larger caps. Database time per tenant is measured and capped in [Find and contain noisy neighbours](https://agentwranglers.se/playbook/data/multi-tenancy/noisy-neighbours.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
const MAX_RUNNING_EXPORTS = 3;

export async function startExport(redis, tenantId, start) {
  const key = `running-exports:${tenantId}`;
  if (await redis.incr(key) > MAX_RUNNING_EXPORTS) {
    await redis.decr(key);
    return { status: 429, retryAfterSeconds: 30 };
  }
  await redis.expire(key, 3600);
  return start({ onDone: () => redis.decr(key) });
}
```

### Python example

```python
MAX_RUNNING_EXPORTS = 3

def start_export(redis, tenant_id: str, start):
    key = f"running-exports:{tenant_id}"
    if redis.incr(key) > MAX_RUNNING_EXPORTS:
        redis.decr(key)
        return {"status": 429, "retry_after_seconds": 30}
    redis.expire(key, 3600)
    return start(on_done=lambda: redis.decr(key))
```

## Sources

- [Google SRE book, Handling Overload](https://sre.google/sre-book/handling-overload/)

## Related rules

- DAT-73 [Find and contain noisy neighbours](https://agentwranglers.se/playbook/data/multi-tenancy/noisy-neighbours.md) in Data and databases
- APS-49 [Limit how often anyone can call your APIs](https://agentwranglers.se/playbook/application-security/limits-and-business-logic/rate-limits.md) in Application security
- AGT-24 [Set quotas per agent grant](https://agentwranglers.se/playbook/agents-as-users/quotas-and-pricing/quota-per-grant.md) in Agents as users
- USG-13 [Alert when a customer costs more than they pay](https://agentwranglers.se/playbook/usage-billing/margins-and-model-cost/customer-margin-alert.md) in Usage-based billing
- MED-27 [Count each owner's storage and enforce a quota](https://agentwranglers.se/playbook/files-and-media/quotas-and-cost/storage-quotas.md) in Files and media

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/scaling/exports-and-fair-share/per-tenant-limits">Agent Wranglers scaling playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Build large exports ahead of time](https://agentwranglers.se/playbook/scaling/exports-and-fair-share/build-exports-ahead.md)
- [Exports and fair share](https://agentwranglers.se/playbook/scaling/exports-and-fair-share.md)
