Search code examples
jenkinsjenkins-pipelinejenkins-plugins

How to do the load-balance to Jenkins master nodes ? (Not HA)


I know Jenkins is the Master-Slave architecture. And it can dispatch the task to slave node.

The Master node like the controller to receive/handle the request from Jenkins Portal、Jenkins CLI command and the api requests. After master receive the request , it could decide the CI/CD task to running on Master node or Slave node by Lable. Master node also host the Jenkins Portal and manage the related config files and pulgins.

The above situation is One Master to multi Slave nodes architecture: enter image description here

However , if a lot of user/api requests to Master node , it would be very busy. Even master could distpatch the task to other slave node , it also need to hadle the request from user/api first.

Therefore , could Jenkins achieve the Multi Master to Mult Slave node architeure: enter image description here

I try to install two Jenkins Master on same machine , and let thist two masters to use the same folder. One is 8080 port , the other is 8082 port.

After experiment , when i create the job on 8080 port , the other 8082 port could not see this job. I have to reload the 8082 port.

Therefore , it seems could not achieve the load balance to Master nodes.


Solution

  • Jenkins idea of horizontal scaling is to add more independent controllers, with their own jobs and agents, serving different teams or different lifecycle stages. To quote documentation:

    Horizontal growth is the creation of additional Jenkins controllers to accommodate new teams or projects, rather than adding new teams or projects to an existing controller.

    Jenkins doesn't have any of the components required to share jobs or agents.

    But it's pretty hard to overwhelm a controller running on a dedicated server with enough CPU and memory. Running a lot of groovy code in every job would be one way to do it. And I mean a lot.