Skip to content

๐ŸŒ A lightweight, efficient HTTP load balancer developed in Go

Notifications You must be signed in to change notification settings

muruga21/LoadDistrix

Repository files navigation

Load Distrix

Load Distrix is a simple HTTP load balancer written in Go. It distributes incoming HTTP requests across multiple backend servers, ensuring high availability and fault tolerance. The load balancer uses a weighted round-robin algorithm to cycle through the available backend servers, automatically retrying requests on failure and marking unresponsive servers as down.


Features ๐Ÿ”ฎ

  • Round-Robin (weighted) Load Balancing: Distributes requests evenly across backend servers.
  • Health Checks: Continuously monitors the status of backend servers.
  • Automatic Retry: Retries requests up to three times in case of failure.
  • Dynamic Server Pool: Automatically adjusts to backend server availability.

Requirements

  • Go 1.16 or higher
  • A configured JSON file named LoadDistrix.config.json with backend server details.

Usage

  1. Clone the repository:

    git clone https://github.com/muruga21/LoadDistrix.git
    cd loaddistrix
  2. Prepare the configuration file:

    write loadbalancer config file in the root directory with the following structure:

    {
      "backend": [
        {
          "host": "server1",
          "url": "http://127.0.0.1:8081"
        },
        {
          "host": "server2",
          "url": "http://127.0.0.1:8082"
        }
      ]
      ...continue with your backend configuration
    }
    [backend]
    host="server1"
    url="http://127.0.0.1:8081"
    [backend]
    host="server2"
    url="http://127.0.0.1:8082"
    
    ... continue with your backend configuration
    backend:

3. Build and run the load balancer:

```sh
go build -o loaddistrix main.go
./loaddistrix <config-file>
  1. The load balancer will start on port 8000. You can now send HTTP requests to http://localhost:8000, and they will be distributed across your configured backend servers.

Configuration ๐Ÿ“ฌ

To configure loadbalancer, write a configuration file with your choice of file extension. Each backend server should be specified with its host and url.

Example:

{
  "backend": [
    {
      "host": "server1",
      "url": "http://127.0.0.1:8081"
    },
    {
      "host": "server2",
      "url": "http://127.0.0.1:8082"
    }
  ]
  ...continue with your backend configuration
}
[backend]
host="server1"
url="http://127.0.0.1:8081"
[backend]
host="server2"
url="http://127.0.0.1:8082"

... continue with your backend configuration
 backend:
- host: "server1"
 url: "http://127.0.0.1:8081"
- host: "server2"
 url: "http://127.0.0.1:8082"

 ...continue with your backend configuration

โšก Featured In:

Open Source Programs

Event Logo Event Name Event Description
GSSoC 24 GirlScript Summer of Code 2024 GirlScript Summer of Code is a three-month-long Open Source Program conducted every summer by GirlScript Foundation. It is an initiative to bring more beginners to Open-Source Software Development.

Our Contributors โค๏ธ


Support

Don't forget to leave a star for this project!

Go to Top

About

๐ŸŒ A lightweight, efficient HTTP load balancer developed in Go

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages