Skip to content

hcchi/golb

 
 

Repository files navigation

Go LB

Build Status Coverage Status godoc

Yet another load balancer golb

Features

  • roundrobin: smooth weighted roundrobin method
  • chash: cosistent hashing method
  • balancer: multiple LB instances, passive health check, SSL offloading
  • controller: dynamic configuration, REST API to start/stop/add/remove LB at runtime
  • statistics: HTTP method/path/code/bytes

Let's try

configuration

The configurations specify that controller listens on 127.0.0.1:6587, and define a virtual server including two servers with the default roundrobin method

{
  "controller": {
      "address": "127.0.0.1:6587",
      "auth": {
          "username": "admin",
          "password": "admin"
      }
  },
  "virtual_server": [
    {
      "name": "web",
      "address": "127.0.0.1:8081",
      "pool": [
        {
          "address": "127.0.0.1:10001",
          "weight": 1
        },
        {
          "address": "127.0.0.1:10002",
          "weight": 2
        }
      ]
    }
  ]
}

steps

  • Terminal #1: make run
  • Terminal #2: watch 'curl -H "Host:localhost" http://127.0.0.1:8081 > /dev/null'
  • Terminal #3: python -m SimpleHTTPServer 10001 & python -m SimpleHTTPServer 10002 & python -m SimpleHTTPServer 10003
  • Terminal #4:

query basic stats

curl -u admin:admin http://127.0.0.1:6587/stats
curl -u admin:admin http://127.0.0.1:6587/vs
curl -u admin:admin http://127.0.0.1:6587/vs/web

add/remove pool member

curl -XPOST -u admin:admin -d '{"address":"127.0.0.1:10003"}' http://127.0.0.1:6587/vs/web/pool
curl -u admin:admin http://127.0.0.1:6587/vs/web
curl -u admin:admin http://127.0.0.1:6587/stats

curl -XDELETE -u admin:admin -d '{"address":"127.0.0.1:10003"}' http://127.0.0.1:6587/vs/web/pool

enable/disable LB instance

curl -XPOST -u admin:admin -d '{"action":"disable"}' http://127.0.0.1:6587/vs/web
curl -u admin:admin http://127.0.0.1:6587/vs/web
curl -XPOST -u admin:admin -d '{"action":"enable"}' http://127.0.0.1:6587/vs/web

About

🐙 Yet another load balancer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 97.3%
  • Shell 2.3%
  • Makefile 0.4%