Skip to content

BrianLusina/robin-lb

Repository files navigation

Robin LB

License Version Tests Lint Build Codacy Badge Go

A simple load balancer in Go. It uses RoundRobin algorithm to send requests into set of backends and support retries too.

It also performs active cleaning and passive recovery for unhealthy backends.

Since its simple it assume if / is reachable for any host its available

How to use

Run the application with:

go run app/cmd/server/main.go --backends=<BACKEND_URL>

Ensure that you have a backend running on the specified url BACKEND_URL

Options available are beloe:

Usage:
  -backends string
        Load balanced backends, use commas to separate
  -port int
        Port to serve (default 3030)

Example:

To add followings as load balanced backends

robinlb --backends=http://localhost:3031,http://localhost:3032,http://localhost:3033,http://localhost:3034

You can optionally run with the provided docker-compose.yml.

docker-compose up

Will build the load balancer and run it on port 3030 and run the other services in the docker-compose file as well.

Afterwards, you can access the load balancer at http://localhost:3030/ and requests will be sent to the appropriate backend.