/go-balance

layer 7 load balancer

Primary LanguageGo

GO-balancer

GO-balancer is a layer 7 load balancer that supports http and https, and it is also implements load balancing algorithms.

It currently supports load balancing algorithms:

  • round-robin
  • random
  • ip-hash
  • least-load

Run

Balancer needs to configure the config.yaml file, see config.yaml :

and now, you can execute balancer, the balancer will print the configuration details:

Schema: http
Port: 8080
Health Check: true
Location:
        Route: /
        Proxy Pass: [http://192.168.1.1 http://192.168.1.2:1015 https://192.168.1.2 http://my-server.com]
        Mode: round-robin

balancer will perform health check on all proxy hosts periodically. When the site is unreachable, it will be removed from the balancer automatically . However, balancer will still perform health check on unreachable sites. When the site is reachable, it will add it to the balancer automatically.

also, each load balancer implements the balancer.Balancer interface:

type Balancer interface {
	Add(string)
	Remove(string)
	Balance(string) (string, error)
	Inc(string)
	Done(string)
}