Skip to content

Latest commit

 

History

History
77 lines (60 loc) · 2.33 KB

README.md

File metadata and controls

77 lines (60 loc) · 2.33 KB

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.