How does Jenkins monitor the resource scheduling status of the agents?

I’m working on the Jenkins load balancing solution. I have a controller node and two agent nodes A and B. build task is executed on the agent node. If node A occupies a large amount of resources, how can I monitor the resources in real time and allocate tasks to the two nodes in a balanced manner?

Jenkins executor scheduling is linear and doesn’t perform well in two situations:

  • scheduling work across a lot of nodes
  • scheduling work across few nodes with a lot of executors.

The same problem exists in node provisioners. I fixed the provisioner issue in yet another docker plugin but it was only fixed there. Ideally, this would be fixed in a lower level API so multiple plugins benefit.

Old fix was merged https://github.com/KostyaSha/yet-another-docker-plugin/pull/167