GithubHelp home page GithubHelp logo

ikedam / scoring-load-balancer-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jenkinsci/scoring-load-balancer-plugin

0.0 1.0 0.0 104 KB

Jenkins plugin to decides a build run on which node by scoring nodes.

License: MIT License

Java 91.31% HTML 8.69%

scoring-load-balancer-plugin's Introduction

Scoring Load Balancer plugin

Jenkins plugin to decides a build run on which node by scoring nodes.

What's this?

Scoring Load Balancer is a Jenkins plugin. This plugin provides following features:

  • Decides a node where a build run depending on scores of nodes.
  • Provides following scoring rules. New ones can be added using ExtensionPoint.
    • Scoring by Build Results
      • Prefers nodes where the last builds of the project succeeded.
      • Avoids nodes where the last builds of the project failed.
    • Scoring by Node Loads
      • Prefers nodes where more executers remain.
      • Avoids nodes where more builds run.
    • Scoring by Node Preferences
      • Prefers nodes marked "Preferred" in configuration of the building project.
      • Prefers nodes with labels marked "Preferred" in configuration of the building project.
      • Prefers nodes marked "Preferred" in configuration of nodes.
  • Scoring rules are configured in "Manage Jenkins" > "Configure System"
    • Pick up available scoring rules and put them in preferred order.
      • Each scoring rules provides its configuration.
      • You can put scoring rules twice or more, but it might be useless for current providing methods.

How does this work?

You may read later "WorkChunks and ExecutorChunks" first for understanding how Jenkins works for build assignment.

This plugin works as following:

  1. When the plugin loaded, replaces the default LoadBalancer to ScoringLoadBalancer
  2. Jenkins requests to map builds to nodes (LoadBalancer#map)
  3. Pick the first WorkChunk (that is, subtask).
  4. Score all nodes by calling all configured ScoringRule
    • You can define a new scoring rule by creating a subclass of ScoringRule.
  5. Pick the ExecutorChunk with the highest score node. Assign that ExecutorChunk to the current WorkChunk.
  6. Pick the next WorkChunk, and back to 4. Scoring is performed for each WorkChunk, for the case scores differ for each subtask.
  7. If assignment is failed (e.g. some constrains is broken), pick the next ExecutorChunk, and back to 6.
  8. If assignment is succeeded, it is used.

WorkChunks and ExecutorChunks

In simple cases, Jenkins launches only one build at the same time. Though multi-configuration project results in multiple builds even triggered once, these builds are launched just one by one sequentially.

But there are cases Jenkins launches two or more builds at the same time. SEE JobProperty#getSubTasks or SubTaskContributor for details.

Before builds start on node, Jenkins requests to map tasks to executors. Here are definitions of words:

Word Explanation
Task A root source of builds. Includes FreeStyleProject, MatrixConfiguration. MatrixProject is also a task, but not processed with LoadBalancer (for it is a FlyWeightTask).
SubTask A task may contain multiple subtasks. One subtask creates one build. Generally, a task contains itself as a subtask. For example, task FreeStyleProject contains a subtask FreeStyleProject itself and other subtasks created by JobProperty#getSubTasks or SubTaskContributor.
Build A process runs on a computer. A build is created by a subtask.
Node One can be registered in "Manage Nodes".
Computer A node which is connected and builds can run on now.
Executor Build slots a computer provides. The number of executer of a node can be configured with "# of executors" in "Manage Nodes" page.

When Jenkins requests to map tasks to executors, it passes WorkChunks and ExecutorChunks.

WorkChunk groups subtasks that must run on a same node. Subtasks can be grouped by SubTask#getSameNodeConstraint returning the same Object.

ExecutorChunk groups executors by their computers (that is by nodes).

Extension point

New scoring rule can be added with extending ScoringRule, overriding the following method:

public abstract boolean updateScores(Task task, WorkChunk wc, Mapping m, NodesScore nodesScore);

You can score nodes by updating nodesScore.

Limitations

  • A performance problem may occurs for a large number of nodes. ** I've tested the behavior with only 10 nodes.

scoring-load-balancer-plugin's People

Contributors

ikedam avatar daniel-beck-bot avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.