traffic-balancer

command module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 1 Imported by: 0

README ยถ

Traffic Balancer

Load Balancing Algorithm

  • least-time
  • weighted-round-robin
  • connection-per-time
  • round-robin

Description ๐Ÿ“š

  • least-time: The load balancer will analyse and monitor the lower average latency of the provided servers and redirect the request to that server.
  • weighted-round-robin: On booting the load balance, it will read from the configuration file the weight of every server and redirect the request to the server with the highest weight rate.
  • connection-per-second: On booting the load balancer, it will check the number of connections on every server, and it will make that server inactive if the number of requests redirected per 1 minute exceeded the provided configuration of that server.
  • round-robin: It will redirect the request per index.

The load balancer checks the server's health status every 1 minute.

Configuration ๐Ÿšง

Updating the config/config.yaml file:


# least-time
# weighted-round-robin
# connection-per-time
# round-robin
algorithm: "weighted-round-robin" # Algorithm to be used
port: 3030 # Port that the reverse proxy will run on
strict: true # Strict mode for black-listing IPs
log: true # Save logs to file in log folder
access-control-allow-origin: "*" # CORS HEADERS
max-body-size: 1024 # Maximum body size!
xss-protection: true # In default true it will add xss protection header to the requested sent from load balancer to the server.
servers: #List of servers.
  - 
    host: "http://localhost:9876"
    weight: 0.1
    connections: 1
  
  - 
    host: "http://localhost"
    weight: 0.9
    connections: 100

Usage ๐Ÿš€

go build
./traffic-balancer 
Load Balancer started at :3030

โš  don't forget to add your servers in the config/config.yaml file

TO-DO ๐Ÿคพโ™‚

  • Adding more Access-Control-Allow header.
  • Add more load balancer algorithms.
  • Write unit tests.
  • Add XSS Header protection.
  • Add Body size.
  • Add MTLS.
  • Add Max File Size!
  • Strict mode for blocking black listing IPs.
  • Gzip Compression.

LICENSE โš–

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation ยถ

The Go Gopher

There is no documentation for this package.

Directories ยถ

Path Synopsis

Jump to

Keyboard shortcuts

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