This project is a basic implementation of a load balancer in Go using the Round Robin algorithm. The load balancer distributes incoming HTTP requests to a set of backend servers in a circular order. The project also has Three RESTApi.
- Distributes client requests/network load efficiently across multiple servers
- Ensures high availability and reliability by sending requests only to servers that are online
- Provides the flexibility to add or subtract servers as demand dictates
- Build a load balancer that can send traffic to two or more servers.
- Health check the servers.
- Handle a server going offline (failing a health check).
- Handle a server coming back online (passing a health check).
- Net/HTTP
- Gin
- Round Robin Logic: Custom implementation of the Round Robin algorithm to distribute requests evenly across multiple backend servers.
- Go 1.16 or higher
- Git
-
Clone the repository:
git clone https://github.com/arpit529srivastava/Why-Take-Load.git cd your-repo-name
-
Install dependencies: intitalize the go mod
go mod init ...... go mod tidy
-
first run the other apis go files
go run api1.go go run api2.go go run api3.go
- Start the load balancer:
go run main.go
- Access the APIs using a tool like
curl
or Postman:curl http://localhost:8080
Once everything is up and running, you can send HTTP requests to the load balancer, and it will distribute them to the backend servers using the Round Robin algorithm.
- Fork the repository
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
Distributed under the MIT License. See LICENSE
for more information.