---
title: "Size workers and pools from rate times · Agent Wranglers"
url: https://agentwranglers.se/playbook/scaling/measure-before-you-scale/size-from-rate-and-duration
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Size workers and pools from rate times duration

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Measure before you scale](https://agentwranglers.se/playbook/scaling/measure-before-you-scale.md).

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

- ID: SCL-4
- Level: Recommended
- Chapter: [Measure before you scale](https://agentwranglers.se/playbook/scaling/measure-before-you-scale)
- Rule: Work out how much work runs at once as the arrival rate times the time each item takes. Size threads, workers and connection pools from that number, not by guessing.
- How: This is Little's law. At 200 requests per second that each take 50 ms, 10 requests are in flight on average. Peaks and slow requests need more, so use the peak rate and the 99th percentile time. A pool far larger than this only moves the queue into the database. Take both numbers from [rate, errors and duration](https://agentwranglers.se/playbook/operations/metrics-and-traces/red-metrics). Keep the total of every pool under the database limit, as [Fit the connection budget to the autoscaling maximum](https://agentwranglers.se/playbook/scaling/growing-the-database/connection-budget) says.
- Check: Each pool's size is within a factor of 2 of the peak rate times the 99th percentile time over the last 30 days. Under the load test, the 95th percentile wait for a pool connection stays under 10 ms.

## 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 HEADROOM = 1.5;

export function poolSize({ peakPerSecond, p99Seconds }) {
  return Math.ceil(peakPerSecond * p99Seconds * HEADROOM);
}

poolSize({ peakPerSecond: 200, p99Seconds: 0.12 }); // 36
```

### Python example

```python
import math

HEADROOM = 1.5

def pool_size(peak_per_second: float, p99_seconds: float) -> int:
    return math.ceil(peak_per_second * p99_seconds * HEADROOM)

pool_size(200, 0.12)  # 36
```

## Related rules

- [Measure rate, errors and duration](https://agentwranglers.se/playbook/operations/metrics-and-traces/red-metrics) in Operations
- [Fit the connection budget to the autoscaling maximum](https://agentwranglers.se/playbook/scaling/growing-the-database/connection-budget) in Scaling

**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/measure-before-you-scale/size-from-rate-and-duration">Agent Wranglers scaling playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Write down the load you plan for](https://agentwranglers.se/playbook/scaling/measure-before-you-scale/load-model)
- Next: [Make one server fast before you add more](https://agentwranglers.se/playbook/scaling/measure-before-you-scale/scale-up-first)
- [Measure before you scale](https://agentwranglers.se/playbook/scaling/measure-before-you-scale)
