Git Product home page Git Product logo

haproxy.agentcheck's Introduction

Haproxy.AgentCheck

Quality Gate Status Coverage Maintainability Rating Security Rating Technical Debt

This application is a lightweight external agent installed on servers / VM / pods, exposing TCP & HTTP endpoints to report the server’s state to Haproxy LB. It's based on Kestrel / .NET Core 3.1, so it's very light.

With the reported health metric, Haproxy can dynamically adjust backend weight, and evenly load balance traffic between hosts. When a host metric spikes (ex a CPU going to 100% because of a VM on a failing host, or an infinite loop made by a tired developer), the reported weight to Haproxy is minimum, telling Haproxy to schedule the minimum traffic to this host.

This feedback loop reduce the blast radius in case of resource exhaustion.

External agents have an edge over other types of health checks: they can send signals back to Haproxy to force some kind of change in state. For example, they can mark the server as up or down, put it into maintenance mode, change the percentage of traffic flowing to it, or increase and decrease the maximum number of concurrent connections allowed. The agent will trigger your chosen action when some condition occurs, such as when CPU usage spikes or disk space runs low.

See "Gauging Health with an External Agent" on Haproxy blog.

In practice :

  • You set a limit to 90% CPU on each probe in a 5 host cluster.
  • In Haproxy configuration, you have a weight of 100 for all 4 backends.
  • The Haproxy.AgentCheck on one host is called by Haproxy on TCP.
  • Suddenly one host is at 40% CPU, Haproxy.AgentCheck returns the value : up 13%.
  • Then Haproxy adjust the backend weight for this host, doing so prioritizes hosts with more resource available.

You can see the adjusted backend weights on the Haproxy-Gui directly (response is up 87% in the screenshot) :

adjusted backends

Supported OS, metrics

Currently, this application supports windows and linux, and the following metrics

  • CPU
  • IIS requests (windows only)

Installation

Haproxy.AgentCheck should be installed as a windows service, in order to be independent of eventual IIS resource exhaustion.

Configuration

Settings are defined via appsettings.config

  "AgentCheckConfig": {
    "RefreshIntervalInMs": 2000,
    "CpuLimit": 90,
    "IisRequestsLimit": 40,
    "SystemResponse": "FirstOrder"
  }

System response

Currently, two system responses are available :

  • Linear : weight is computed to be linear to a defined limit. This is the best choice for environment where all nodes are homogeneous (IPC, number of cores, etc.), and all requests on the servers have the same resource consumption (CPU, etc).
  • FirstOrder : weight is a first order system response. Best suited for heterogeneous environments, where

Example with a 80% limit : System Response

All curves are crafted to return 100% when x = 0, and 1% when x = limit. (x is the current metric value, like CPU%). Returning 1 is a safety to avoid a full backend drain (happening if we return 0).

You can play with the curves on this link (the variable c is the limit you will define in appsettings, like CpuLimit).

haproxy.agentcheck's People

Contributors

lucca-renovate[bot] avatar natmarchand avatar rducom avatar seguins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

carahsoft

haproxy.agentcheck's Issues

use full Haproxy weight [1-256]

The "weight" parameter is used to adjust the server's weight relative to
other servers. All servers will receive a load proportional to their weight
relative to the sum of all weights, so the higher the weight, the higher the
load. The default weight is 1, and the maximal value is 256. A value of 0
means the server will not participate in load-balancing but will still accept
persistent connections. If this parameter is used to distribute the load
according to server's capacity, it is recommended to start with values which
can both grow and shrink, for instance between 10 and 100 to leave enough
room above and below for later adjustments.

Current implementation only go to 100

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore(deps): update dependency dotnet-sdk to v8.0.301

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update actions/checkout digest to a5ac7e5
  • chore(deps): update gittools/actions action to v1
  • πŸ” Create all rate-limited PRs at once πŸ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Vulnerabilities

Renovate has not found any CVEs on osv.dev.

Detected dependencies

github-actions
.github/workflows/dotnetcore.yml
  • actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/setup-dotnet v4@4d6c8fcf3c8f7a60068d26b594648e99df24cee3
  • gittools/actions v0.10.2@a41619580c25efb59dfc062e92990914141abcad
  • gittools/actions v0.10.2@a41619580c25efb59dfc062e92990914141abcad
  • actions/upload-artifact v4@26f96dfa697d77e81fd5907df203aa23a56210a8
  • actions/upload-artifact v4@26f96dfa697d77e81fd5907df203aa23a56210a8
  • actions/create-release v1@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e
  • actions/upload-release-asset v1@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
  • actions/upload-release-asset v1@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
nuget
Directory.Packages.props
  • Microsoft.CodeAnalysis.BannedApiAnalyzers 3.3.4
  • SonarAnalyzer.CSharp 9.19.0.84025
  • xunit.runner.visualstudio 2.5.6
  • xunit 2.6.6
  • coverlet.msbuild 6.0.0
  • Microsoft.NET.Test.Sdk 17.8.0
  • System.IO.Pipelines 8.0.0
  • System.Diagnostics.PerformanceCounter 8.0.0
  • Serilog.Sinks.File 5.0.0
  • Serilog.Settings.Configuration 8.0.0
  • Serilog.Enrichers.Process 2.0.2
  • Serilog.Enrichers.Environment 2.3.0
  • Serilog.Enrichers.AssemblyName 1.0.9
  • Serilog.AspNetCore 8.0.1
  • Microsoft.Extensions.Hosting.WindowsServices 8.0.0
  • Microsoft.Extensions.Hosting.Systemd 8.0.0
  • Microsoft.Extensions.Diagnostics.Testing 8.2.0
  • Microsoft.Diagnostics.Tracing.TraceEvent 3.1.8
  • Microsoft.Diagnostics.NETCore.Client 0.2.505301
  • Microsoft.AspNetCore.Mvc.Testing 8.0.2
global.json
  • dotnet-sdk 8.0.201

  • Check this box to trigger a request for Renovate to run again on this repository

Workflows are referencing vulnerable actions

Hello, there!

As part of the university research we are currently doing regarding the security of Github Actions, we noticed that one or many of the workflows that are part of this repository are referencing vulnerable versions of the third-party actions. As part of a disclosure process, we decided to open issues to notify GitHub Community.

Please note that there are could be some false positives in our methodology, thus not all of the open issues could be valid. If that is the case, please let us know, so that we can improve on our approach. You can contact me directly using an email: ikoishy [at] ncsu.edu

Thanks in advance

  1. The workflow dotnetcore.yml is referencing action gittools/actions/gitversion/setup using references v0.9.2. However this reference is missing the commit 90150b4 which may contain fix to the vulnerability.
  2. The workflow dotnetcore.yml is referencing action gittools/actions/gitversion/execute using references v0.9.2. However this reference is missing the commit 90150b4 which may contain fix to the vulnerability.

The vulnerability fix that is missing by actions' versions could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider updating the reference to the action.

If you end up updating the reference, please let us know. We need the stats for the paper :-)

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.