Repository navigation
feat(build): queue builds by the account's free memory - #268
Open
martinsifra wants to merge 1 commit into
Open
martinsifra wants to merge 1 commit into
martinsifra wants to merge 1 commit into
Conversation
Every Actor's build used to start at once. Each build takes 4096 MB, so on an account whose free memory can't hold them all, the platform refused the extra builds and the whole build step failed. Builds now run in a queue per account (per token): as many at once as the free memory from the account limits holds, starting the next one whenever a build finishes. The limits can lag behind the platform, so a build the platform still refuses for lack of memory goes back to the end of the queue and the parallel builds shrink to the ones running. It gives up 30 minutes after its first refusal. A build that starts and then fails is not re-run. Local builds upload their source zip once, even when queued again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
martinsifra
requested review from
JuanGalilea,
metalwarrior665 and
ruocco-l
as code owners
December 2, 2026 09:32
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
runAndSummarizeBuildsstarts the build of every affected Actor at once. Each platform build takes 4096 MB (builds docs), and the build API has no parameter to change that. When the account's free memory can't hold all the builds together, the platform refuses the extra ones and the whole build step fails.Change
Builds now run in a queue per account, so they finish as fast as the account's memory allows without failing for lack of it.
GET /users/me/limits(maxActorMemoryGbytes - actorMemoryGbytes). The queue runsmax(1, floor(free / 4096))builds at once and starts the next Actor whenever one finishes. When the token can't read the limits, every build starts at once and refusals are handled as below.actor-memory-limit-exceededorconcurrent-runs-limit-exceeded, or with a 402 whose message mentions memory or concurrency. The refused Actor goes to the end of the queue, and the number of builds at once shrinks to the ones running. It's tried again when one of them finishes, or every 30 s when none of this account's builds is running. It gives up 30 minutes after its first refusal.build-from-localuploads each Actor's source zip once, even when the Actor is queued again.[APIFY_TOKEN_X]: 8192 MB of free memory, building 2 of 5 Actors at once (4096 MB each).Not verified yet
actor-memory-limit-exceededcomes from the API's error-type list. I haven't seen it returned on a refused build start.current.actorMemoryGbytesincludes builds that are running.Tests
test/unit/bin/build.test.tsadds tests for:isCapacityLimitError)🤖 Generated with Claude Code