Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

balancer

Load balancer that was presented at HighLoad++ 2015 Conference in Moscow

Subscribe to updates I use balancer


Statistics on balancer

Number of watchers on Github 38
Number of open issues 0
Main language PHP
Open pull requests 0+
Closed pull requests 0+
Last commit almost 4 years ago
Repo Created almost 4 years ago
Repo Last Updated over 1 year ago
Size 8 KB
Organization / Authorbadoo
Contributors1
Page Updated
Do you use balancer? Leave a review!
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating balancer for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

balancer

Load balancer that was presented at HighLoad++ 2015 Conference in Moscow.

The load balancer is intended to fine-tune weights for upstream servers that you already have so that you get even balancing. In order to use it, you must implement all abstract methods and call run() method. If application exits with non-zero code then it means that something went wrong and you should see log for details.

You must implement the following methods:

getCurrentServerWeights:

Parse your config file (see NginxBalancer class as an example) and return all current weights that you have in config.

updateServerWeights($new_weights, $to_delete):

Update weights for existing hosts in a config file and add new hosts into config as well (this information is provided by $new_weights variable). Also delete hosts that are present in $to_delete section.

needCheckHTTP:

Whether or not you should check the HTTP heartbeat for hosts that you already have in you config file. If you return false then only new hosts will be checked with a heartbeat.

outputIsOk($hostname, $output):

Function to check that HTTP output of a heartbeat request that was sent to $hostname is a correct one. If you always return false here then no new hosts can be added.

getAliveHosts:

Get hosts that are alive using any central database you have (it is different from getCurrentServerWeights in a way that you actually provide the list of hosts from zabbix or something similar rather that hosts that are present in config file).

getCpuIdleStats($hostname):

Return information about the host CPU usage, number of cores and also provide information on how long ago you received the information. The latter is necessary so that you do not try to make weights tuning based on stale data.

canDisableHosts($host_weights, $hosts_to_disable, &$reason = ''):

Whether or not you can disable the provided number of hosts from balancing (useful only when needCheckHTTP returns true). It is suggested that you check peak CPU usage of your cluster without the provided hosts. An example implementation is provided in BaseBalancer class in comments.

Testing

You can see test for Base Balancer that can be seen at BaseBalancerTest.php. You run it as phpunit BaseBalancerTest.php. The test provides minimal implementation for an actual balancer and checks that basic functionality works using default settings.

balancer questions on Stackoverflow (View All Questions)
  • Symfony2 uses wrong "x-forwarded-for" on AWS Load Balancer / 2 Ip addresses
  • Java: Get Ip Adress of a Server behind DNS Load Balancer
  • How to make sure that a job runs only once / or only by one of the 5 load balancer servers
  • Rails 4 + Websocket-rails + Passenger + Nginx + Load balancer
  • What are the differences between Network and HTTP(s) load balancer in GCP
  • Socket.io Websockets on a TCP configured Amazon Elastic Load Balancer
  • RabbitMQ health check with Google Cloud load balancer
  • IIS showing default page when website stopped intead of sending 404 error when behind load balancer F5
  • How to access security group of classic load balancer?
  • oAuth with Elastic Load Balancer SSL
  • Can't start the docker image of the restcomm load balancer
  • docker nginx stream balancer 404
  • Azure Container Services Port Load Balancer
  • Manage AWS Elastic Load Balancer instances
  • AWS EC2 Application Load Balancer + Two-Way SSL?
  • how to use multiple ssl certificates in single google cloud load balancer for multiple domains pointed to same load balancer
  • Azure Load Balancer + NSG Rules - Remove Access Directly
  • Wordpress get_template_directory_uri() behind load balancer
  • Tomcat to reply back to load balancer IP when request comes
  • SilverStripe behind load balancer
  • CSS, JS and other static contents are not loading for liferay 7 with Apache load balancer
  • Is it a good practice to send back backend server ip:port to client through load balancer
  • Coldfusion - Get user's IP when application is behind a load balancer
  • Socket.io behind HAProxy behind Google Cloud load balancer giving connection errors
  • Creating a HTTP load balancer in Google Cloud Platform
  • zen load balancer virtual IP is masking origin SMTP IP which is leading to false spam in Exchange
  • Authentication failed when coturn is behind the udp load balancer like nginx
  • AAR as Load Balancer for application using NginX as reverse proxy, does not authenticate url
  • Amazon load balancer with my own domain
  • How to use django-compressor behind load balancer?
balancer list of languages used
Other projects in PHP