Skip to content

reqstorm 2.5.0: concurrency="auto" and the open file limit - #21

Merged
melihcolpan merged 2 commits into
masterfrom
auto-concurrency
Oct 10, 2026
Merged

melihcolpan merged 2 commits into
masterfrom
auto-concurrency

Conversation

@melihcolpan

Copy link
Copy Markdown
Owner

concurrency="auto": finds how many attempts at once the servers handle well (TCP-style: slow start, fast backoff on 429/5xx/timeouts, ease off on slowdowns, per-host normal latency, epochs, growth only when used, ceiling + probe). Retry waits don't hold a place.

Measured against a local server that 503s anything over its capacity (600 requests, retries=3):

capacity concurrency=100 concurrency="auto"
3 494/600 ok, +105 % attempts 600/600, +2 %
12 600, +46 % 600, +1 %, faster
40 600, +20 % 600, +6 %
100 600, 0.2 s 600, 1.0 s (warm-up)
slows down under load 100 in flight 9 in flight

Open file limit: concurrency is checked against ulimit -n before sending; the soft limit is raised if possible, otherwise concurrency is lowered with a warning (instead of "Too many open files").

Also: active 12/16 in the progress line, -c auto / --max-concurrency in the CLI, built-in TimeoutError retryable on 3.9/3.10. Docs updated (guide, README, CLI, home page). 301 tests passing on 3.9, 3.12, 3.13.

concurrency="auto"
A fixed concurrency has to be guessed: too high floods a busy API with
rejected attempts, too low wastes time. AutoConcurrency finds it from the
responses, the way TCP congestion control does:

- It limits attempts on the wire, not requests: an attempt takes a place
  just before it is sent and gives it back when the response arrives, so
  a request sleeping before a retry does not count. Limiting whole
  requests made retries look like server load and kept the limit wrong.
- Backoff to 3/4 when more than 5 % of recent attempts met 429/502/503/
  504, a timeout or a dropped connection. It does not wait for the window
  to end: a quarter of the limit in rejections is enough, otherwise a
  server that rejects instantly sees hundreds of attempts per window.
- Each backoff starts an epoch; attempts sent before it are ignored
  afterwards, so one burst is not punished three times (16 -> 12 -> 9 -> 6
  in the first version).
- Ease off to 9/10 when the median response takes twice the host's
  normal (its fastest typical time, tracked per host and drifting up
  slowly), so mixed fast and slow hosts are not confused.
- Growth once per window (>= 0.25 s and 3x the recent response time),
  only when the whole limit was in use: doubling until the first backoff,
  then +10 %. The level that caused pushback is kept as a ceiling; growth
  stops just below it and probes it after 8 healthy windows (CUBIC-like),
  instead of hitting a hard capacity every window.
- DNS, SSL and invalid-URL errors are not load signals.

Measured against a local server that 503s anything over its capacity
(600 requests, retries=3), fixed 100 vs auto:
  capacity 3:   494/600 ok, +105 % attempts  vs  600/600, +2 %
  capacity 12:  600, +46 %                   vs  600, +1 %, faster
  capacity 40:  600, +20 %                   vs  600, +6 %
  capacity 100: 600, 0.2 s                   vs  600, 1.0 s (warm-up)
and against a server that only slows down: 100 vs 9 in flight.
The numbers were stable over three runs.

Open file limit
Each connection is a file descriptor, so concurrency=1000 in a shell
with ulimit -n 256 failed with "Too many open files". fit_concurrency
compares concurrency x pools (+64 reserved) with RLIMIT_NOFILE before
anything is sent, raises the soft limit as far as allowed (trying
OPEN_MAX on macOS), and otherwise lowers the concurrency with a warning
that names the ulimit to use. SOCKS proxies count as extra pools. Skipped
on Windows.

Also
- ProgressInfo.concurrency and "active 12/16" in the progress line;
  changes logged at DEBUG, a summary at INFO.
- CLI: -c auto, --max-concurrency; --estimate uses the maximum.
- The built-in TimeoutError is retryable and a load signal on Python
  3.9/3.10, where it differs from asyncio.TimeoutError.

Tests: controller units with a fake clock (slow start, fast pushback,
epochs, per-host slowness, utilization, ceiling probe, bounds, gate),
end to end against capacity-limited and congestion-slowed routes, the
file limit raised/lowered/Windows paths plus a real subprocess with a
lowered soft limit, and the CLI. Version 2.5.0.
- Rate limits and concurrency guide: why concurrency does not depend on
  CPU cores, how concurrency="auto" decides, the measured comparison with
  a fixed 100 including where a fixed number is faster, and how the open
  file limit is handled.
- README, home page card, progress line ("active 12/16"), command line
  options and the 2.5.0 changelog entry.
@melihcolpan
melihcolpan merged commit 7ac24d4 into master Oct 10, 2026
12 checks passed
@melihcolpan
melihcolpan deleted the auto-concurrency branch October 10, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant