Skip to content

feat(autoscaling)!: Add ConcurrencySystem to share one concurrency budget between crawlers - #2322

Merged
vdusek merged 6 commits into
apify:v2from
Mantisus:split-autoscaled-pool
Oct 21, 2026
Merged

vdusek merged 6 commits into
apify:v2from
Mantisus:split-autoscaled-pool

Conversation

@Mantisus

@Mantisus Mantisus commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Load monitoring and concurrency scaling move from AutoscaledPool into a new ConcurrencySystem. Pass one system to several crawlers through the new concurrency_system option to cap their combined concurrency. The autoscaling classes are now public in crawlee.autoscaling.

Autoscaling logs move to DEBUG, and max_tasks_per_minute now counts the tasks started over the last 60 seconds. Breaking changes are in the v2 upgrade guide.

Issues

✍️ Drafted by Claude Code

@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 14, 2026
@Mantisus Mantisus self-assigned this Oct 14, 2026
@Mantisus
Mantisus force-pushed the split-autoscaled-pool branch 2 times, most recently from a738bbb to 97286df Compare October 14, 2026 18:54
@Mantisus
Mantisus marked this pull request as ready for review October 14, 2026 19:48
@Mantisus
Mantisus requested review from janbuchar and vdusek October 14, 2026 19:48
@Mantisus Mantisus changed the title feat!: Add ConcurrencySystem to share one concurrency budget between crawlers feat(autoscaling)!: Add ConcurrencySystem to share one concurrency budget between crawlers Oct 15, 2026
@vdusek
vdusek requested a review from Pijukatel October 16, 2026 06:50
@vdusek
vdusek force-pushed the split-autoscaled-pool branch 2 times, most recently from 028fd2c to b6e4fad Compare October 16, 2026 07:59
Comment thread docs/guides/scaling_crawlers.mdx
Comment thread src/crawlee/autoscaling/_types.py
Comment thread src/crawlee/autoscaling/_autoscaled_pool.py
Comment thread src/crawlee/autoscaling/_concurrency_system.py Outdated
Comment thread src/crawlee/autoscaling/_concurrency_system.py Outdated
Comment thread src/crawlee/autoscaling/_concurrency_system.py
Comment thread src/crawlee/crawlers/_basic/_basic_crawler.py Outdated
Comment thread src/crawlee/autoscaling/_types.py Outdated
Comment thread docs/upgrading/upgrading_to_v2.md
Comment thread src/crawlee/crawlers/_playwright/_playwright_crawler.py
Comment thread src/crawlee/autoscaling/_concurrency_system.py Outdated
@Mantisus
Mantisus force-pushed the split-autoscaled-pool branch 2 times, most recently from 39a2094 to 9294fec Compare October 18, 2026 16:57
@vdusek
vdusek self-requested a review October 19, 2026 11:19
Comment thread src/crawlee/autoscaling/_autoscaled_pool.py Outdated
@Mantisus
Mantisus force-pushed the split-autoscaled-pool branch from 4dc85f7 to 31e6c82 Compare October 21, 2026 17:16
@Mantisus
Mantisus requested a review from vdusek October 21, 2026 17:16
@vdusek vdusek linked an issue Oct 21, 2026 that may be closed by this pull request

@vdusek vdusek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vdusek
vdusek merged commit 51efb37 into apify:v2 Oct 21, 2026
37 checks passed
vdusek pushed a commit that referenced this pull request Oct 28, 2026
…stop()` to the current run (#2332)

### Description

`AutoscaledPool` now calls `is_finished_function` only when none of its
own tasks are running and it can't start a new one, either because no
task is ready or because a shared concurrency system has no free
capacity. Before, it was called on every loop iteration, even with tasks
in flight.

- Crawlers no longer query the request manager's `is_finished()` every
half second during a crawl, so storage backends get fewer calls.
- A pool whose `is_task_ready_function` always resolves to `True` no
longer finishes. It has to resolve to `False` once the work runs out.
The upgrade guide covers this.
- A paused pool doesn't finish until it's resumed.
- `crawler.stop()` now applies only to the current run. A crawler that
was stopped once used to end every later `run()` immediately.
- After `stop()` or reaching `max_requests_per_crawl`, the crawler logs
once that it takes no new requests and again when the remaining requests
have finished. The stop reason no longer ends with a double period.

### Issues

- Follow-up: #2322
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Share one concurrency budget between multiple crawlers Reduce the autoscaled pool logs at INFO level Make the AutoscaledPool log understandable

3 participants