golb

module
v0.0.0-...-2b4093a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2019 License: MIT

README

Go LB

Build Status Go Report Card 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
  • service discovery: autodiscover backend services with etcd or consul
  • statistics: HTTP method/path/code/bytes
  • conf: yaml and json configuration

Examples

LICENSE

MIT License

Copyright (c) 2018 Larry He

Directories

Path Synopsis
Package chash provides consistent hash balancing "Consistent hashing can guarantee that when a cache machine is removed, only the objects cached in it will be rehashed; when a new cache machine is added, only a fairly few objects will be rehashed." https://www.codeproject.com/Articles/56138/Consistent-hashing consistent hashing with bounded loads https://research.googleblog.com/2017/04/consistent-hashing-with-bounded-loads.html
Package chash provides consistent hash balancing "Consistent hashing can guarantee that when a cache machine is removed, only the objects cached in it will be rehashed; when a new cache machine is added, only a fairly few objects will be rehashed." https://www.codeproject.com/Articles/56138/Consistent-hashing consistent hashing with bounded loads https://research.googleblog.com/2017/04/consistent-hashing-with-bounded-loads.html
cmd
Package controller provides REST API to configure balancer controller API - Authentication Basic HTTP Auth - Stats GET http://{controller_address}/stats - List All LB instance GET http://{controller_address}/vs - Add LB instance POST http://{controller_address}/vs Body {"name":"redis","address":"127.0.0.1:6379"} Example: curl -XPOST -u admin:admin -H 'content-type: application/json' -d '{"name":"redis","address":"127.0.0.1:6379"}' http://127.0.0.1:6587/vs - Enable LB instance POST http://{controller_address}/vs/{name} Body {"action":"enable"} - Disable LB instance POST http://{controller_address}/vs/{name} Body {"action":"disable"} - List pool member of LB instance GET http://{controller_address}/vs/{name} - Add pool member to LB instance POST http://{controller_address}/vs/{name}/pool Body: {"address":"127.0.0.1:10003","weight":2} Example: curl -XPOST -u admin:admin -H 'content-type: application/json' -d '{"address":"127.0.0.1:10003"}' http://127.0.0.1:6587/vs/web/pool - Remove pool member from LB instance DELETE http://{controller_address}/vs/{name}/pool Body: {"address":"127.0.0.1:10002"} Example: curl -XDELETE -u admin:admin -H 'content-type: application/json' -d '{"address":"127.0.0.1:10002"}' http://127.0.0.1:6587/vs/web/pool
Package controller provides REST API to configure balancer controller API - Authentication Basic HTTP Auth - Stats GET http://{controller_address}/stats - List All LB instance GET http://{controller_address}/vs - Add LB instance POST http://{controller_address}/vs Body {"name":"redis","address":"127.0.0.1:6379"} Example: curl -XPOST -u admin:admin -H 'content-type: application/json' -d '{"name":"redis","address":"127.0.0.1:6379"}' http://127.0.0.1:6587/vs - Enable LB instance POST http://{controller_address}/vs/{name} Body {"action":"enable"} - Disable LB instance POST http://{controller_address}/vs/{name} Body {"action":"disable"} - List pool member of LB instance GET http://{controller_address}/vs/{name} - Add pool member to LB instance POST http://{controller_address}/vs/{name}/pool Body: {"address":"127.0.0.1:10003","weight":2} Example: curl -XPOST -u admin:admin -H 'content-type: application/json' -d '{"address":"127.0.0.1:10003"}' http://127.0.0.1:6587/vs/web/pool - Remove pool member from LB instance DELETE http://{controller_address}/vs/{name}/pool Body: {"address":"127.0.0.1:10002"} Example: curl -XDELETE -u admin:admin -H 'content-type: application/json' -d '{"address":"127.0.0.1:10002"}' http://127.0.0.1:6587/vs/web/pool
examples
Package roundrobin provides smooth weighted round-robin balancing > For edge case weights like { 5, 1, 1 } we now produce { a, a, b, a, c, a, a } > sequence instead of { c, b, a, a, a, a, a } produced previously.
Package roundrobin provides smooth weighted round-robin balancing > For edge case weights like { 5, 1, 1 } we now produce { a, a, b, a, c, a, a } > sequence instead of { c, b, a, a, a, a, a } produced previously.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL