72

GitHub - onestraw/golb: Yet another load balancer

 7 years ago
source link: https://github.com/onestraw/golb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

README.md

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 Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK