Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Concurrency Control to Matrix Builds #2581

Open
dennisoehme opened this issue Jul 5, 2024 · 2 comments
Open

Add Concurrency Control to Matrix Builds #2581

dennisoehme opened this issue Jul 5, 2024 · 2 comments

Comments

@dennisoehme
Copy link

dennisoehme commented Jul 5, 2024

Introduce an option to limit the number of concurrent builds when using Docker Buildx (Bake) to manage matrix builds. This feature would help users control system load and optimize resource utilization during complex build processes.

Description

Currently, Docker Buildx Bake allows users to define and run matrix builds, which can potentially execute a large number of targets in parallel. However, there is no built-in option to limit the concurrency of these builds. This can lead to excessive system load, especially on resource-constrained environments.

Proposed Solution

  1. Add a new option to the docker buildx bake command that allows users to specify the maximum number of concurrent build jobs. This option, tentatively named --max-parallel, would control the number of builds executed simultaneously.
  2. Add a concurrency field to the target definitions in the docker-bake.hcl file, enabling users to specify the maximum number of concurrent builds for each target group or individual target.
target "build" {
  inherits = ["_common"]
  name = "${PROJECT}-build"
  matrix = {
    "PROJECT" = [...]
  }
  concurrency = 2
}

Use Case(s)

  • External Download Limits: When Docker builds need to receive downloads from a third-party source that limits the number of parallel requests, controlling concurrency becomes essential. Without such control, exceeding the allowed number of parallel requests can result in build failures or throttling from the third-party service. By specifying concurrency limits in the build configuration, users can ensure compliance with these external constraints while optimizing build efficiency.
  • Differing Target Loads: Different build targets can produce varying loads on the system. For instance, a target that involves heavy compilation or resource-intensive operations might need to be limited to fewer concurrent builds compared to lighter targets. Specifying concurrency limits per target ensures that resource-intensive builds do not overload the system while allowing lighter builds to proceed in parallel, maximizing overall efficiency.

What do you think, guys? :-)


PS: I know we already have the max-parallelism option in buildkitd (moby/buildkit#1131), but this feature request describes a different purpose.

@crazy-max
Copy link
Member

Looks good but don't think this should be specific to matrix but overall invoked build targets so should be only set as flag imo.

@thompson-shaun
Copy link
Collaborator

Related? #359

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants