RoundRobin-Go is a Go middleware implementing the round-robin algorithm for load balancing. It evenly distributes requests across multiple servers or resources in a circular order, enhancing system performance. Easy to integrate, it offers a simple solution for load distribution in Go applications.
- Simple and efficient round-robin load balancing
- Concurrent request handling
- Easy configuration via included JSON and environment files
- Docker support for easy deployment
- Go 1.22 or later
- Git
To get started with RoundRobin-Go, clone the repository to your local machine:
git clone https://github.com/CameronMcConnell/RoundRobin-Go.git
cd RoundRobin-GoThe project includes two pre-configured files:
servers.json: Contains the list of backend servers for load balancing..env: Specifies the server address for the middleware.
You can modify these files to suit your needs:
Edit servers.json to add or remove backend servers:
[
"http://backend1:8081",
"http://backend2:8082",
"http://backend3:8083"
]Adjust the .env file to change the server address if needed:
SERVER_ADDRESS=:8080Run the application:
go run main.goThe server will start on the address specified in the .env file.
Once the server is running, it will distribute incoming requests to the /roundrobin-go endpoint across the configured backend servers in a round-robin fashion.
To build and run RoundRobin-Go using Docker:
- Build the Docker image:
docker build -t roundrobin-go .- Run the container:
docker run -p 8080:8080 roundrobin-goNote: The servers.json and .env files are included in the Docker image during the build process.
main.go: Entry point of the applicationlib/: Contains the core logic for the round-robin serverservers.json: Configuration file for backend servers (included).env: Environment file for server address configuration (included)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.