Load balancer implementation with Go. It is a solution to John Crickett's Coding Challenges.
There are 2 main files:
- lb is the load balancer and it implements a Round Robin algorithm, sending requests to three different servers at ports 8081, 8082 and 8083.
- be is a simple backend server written in Go to answer the GET requests.
Execute make build
to create the executables. It will be saved in the bin/
directory.
Execute three different web servers.
./bin/be -p 8081
./bin/be -p 8082
./bin/be -p 8083
Now, execute the load balancer.
./bin/lb
You can use cURL to make a request to our load balancer.
curl http://localhost:8080
And to simulate multiple requests, you can use wrk.
wrk http://localhost:8080 -t2 -c10 -d2
Execute make test
You should see a result matching something like:
--- PASS: TestHandlesMultipleClientsAtSameTime (1.00s)
PASS
ok github.com/andrenbrandao/load-balancer/test 5.021s
MIT © André Brandão