How can I modify the Load Balancing behavior Jenkins uses to control slaves? [closed]

流过昼夜 提交于 2019-11-27 12:31:23

问题


We use Jenkins for our CI build system. We also use 'concurrent builds' so that Jenkins will build each change independently. This means we often have 5 or 6 builds of the same job running simultaneously. To accommodate this, we have 4 slaves each with 12 executors.

The problem is that Jenkins doesn't really 'load balance' among its slaves. It tries to build a job on the same slave that it previously built on (presumably to reduce the time syncing from source control). This is a problem because Jenkins will build all 6 instances of our build on the same slave (or more likely between 2 slaves). One build machine gets bogged down and runs very slowly while the rest of them sit idle.

Is there a plugin or something that alters the load balancing behavior Jenkins uses to control its slaves?


回答1:


If you do not find a plugin that does it automatically, here's an idea of what you can do:

  • Install Node Label Parameter plugin
  • Add SLAVE parameter to your jobs
  • Restrict jobs to run on ${SLAVE}
  • Add a trigger job that will do the following:

    • Analyze load distribution via a System Groovy Script and decide on which node to start next build.
    • Dispatch the build on that node with Parametertized Trigger plugin by assigning appropriate value to SLAVE parameter.

In order to analyze load distribution you need to install Groovy plugin and familiarize yourself with Jenkins Main Module API. Here are some useful initial pointers.




回答2:


We were facing a similar issue. So I've put together a plugin that changes the Load Balancer in Jenkins to select a node that currently has the least load - https://wiki.jenkins-ci.org/display/JENKINS/Least+Load+Plugin

Any feedback is appreciated.




回答3:


If your build machines cannot comfortably handle more than 1 build, why configure them with 12 executors? If that is indeed the case, you should reduce the number of executors to 1. My Jenkins has 30 slaves, each with 1 executor.




回答4:


You may also use the Throttle Concurrent Builds plugin to restrict how many instances of a job can run in parallel on the same node




回答5:


I have two labels -- one for small tasks and one for big tasks. I have one executor for the big task and 4 for the small tasks. This does balance things a little.



来源:https://stackoverflow.com/questions/11024007/how-can-i-modify-the-load-balancing-behavior-jenkins-uses-to-control-slaves

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!