/gee_loadbalancer

This is a simple load balancer

Primary LanguageGoMIT LicenseMIT

gee_load_load_balancer

Gee_LoadBalancer

Gee_LoadBalancer is a simple load balancing program written in Go language

GeeLoadBalancer has the following characteristics

  • Supports multiple load balancing algorithms
  • Support backend checking
  • Supports automatic addition and deletion of backend services
  • Supports HTTP and HTTPS
  • Supports global streaming

Get Started

First you need to download the GeeLoadBalancer binary file from the releases

Looks cli help

./gee_loadbalancer -h
geeloadbalance is a simple load balancing manager

Usage:
  geeloadbalance [flags]
  geeloadbalance [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  run         run the load balancer
  version     Print the version number of the application

Flags:
  -h, --help   help for geeloadbalance

Use "geeloadbalance [command] --help" for more information about a command.

View the configuration files required by GeeLoadBalancer

listen_schema: http # http or https
listen_port: 8080  # port to listen on
ssl_certificate: ""  # path to ssl certificate file
ssl_certificate_key: ""  # path to ssl certificate key file
tcp_health_check: true  # enable tcp health check
tcp_health_check_interval: 3  # tcp health check interval
max_allowed: 1000  # maximum allowed connections
locations:   # list of locations to balance
- prefix: /  # prefix to match
  balance_mode: random  # load balancing algorithm
  servers:   # list of backend servers to balance
  - "http://127.0.0.1:8081"
  - "http://127.0.0.1:8082"
  - "http://127.0.0.1:8083"

Run GeeLoadBalancer

./gee_loadbalancer run -c config.yaml
    ___       ___       ___       ___       ___       ___       ___       ___       ___       ___       ___       ___       ___       ___   
   /\  \     /\  \     /\  \     /\__\     /\  \     /\  \     /\  \     /\  \     /\  \     /\__\     /\  \     /\__\     /\  \     /\  \
  /::\  \   /::\  \   /::\  \   /:/  /    /::\  \   /::\  \   /::\  \   /::\  \   /::\  \   /:/  /    /::\  \   /:| _|_   /::\  \   /::\  \
 /:/\:\__\ /::\:\__\ /::\:\__\ /:/__/    /:/\:\__\ /::\:\__\ /:/\:\__\ /::\:\__\ /::\:\__\ /:/__/    /::\:\__\ /::|/\__\ /:/\:\__\ /::\:\__\
 \:\:\/__/ \:\:\/  / \:\:\/  / \:\  \    \:\/:/  / \/\::/  / \:\/:/  / \:\::/  / \/\::/  / \:\  \    \/\::/  / \/|::/  / \:\ \/__/ \:\:\/  /
  \::/  /   \:\/  /   \:\/  /   \:\__\    \::/  /    /:/  /   \::/  /   \::/  /    /:/  /   \:\__\     /:/  /    |:/  /   \:\__\    \:\/  /
   \/__/     \/__/     \/__/     \/__/     \/__/     \/__/     \/__/     \/__/     \/__/     \/__/     \/__/     \/__/     \/__/     \/__/

Schema: http
Port: 8080
Interval: 3
Health Check: true
Location:
        Route: /
        Servers: [http://127.0.0.1:8081, http://127.0.0.1:8082, http://127.0.0.1:8083]
        Mode: random

Access The Load Balancer

$ curl.exe 127.0.0.1:8080 -I
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 615
Content-Type: text/html
Date: Tue, 07 May 2024 07:53:36 GMT
Etag: "661e9d7a-267"
Last-Modified: Tue, 16 Apr 2024 15:47:06 GMT
Server: nginx/1.25.5