Available strategies are:
- Round Robin
- Least Busy
These strategies for the node pools are also concurrent safe.
bin/slb -strategy round_robin -config config.json
bin/slb -strategy least_busy -config config.json
The pool was tested by a requester that produces tasks at a random interval, faster than the time it takes to complete the requests itself.
The tasks also take an inconsistent amount of time to finish.
In this example the requests were just sleeps.
The standard deviation measures how spread out the pending requests are across workers, giving us an idea of how well the pool is distributing work.
As time goes by the average load goes up the standard deviation remains about the same!
Basically the smaller the Std Dev the better work is being distributed!
It’s worth noting that because the requests aren’t equal in the amount of work, the round robin balancer’s standard deviation starts to climb.
While the least busy strategy keeps the amount of pending tasks in account and results in a better distribution of requests.
Try The Demo
# clone the project
go get github.com/JackyChiu/slb
# make project
# start local servers (only for demo)
bin/servers -config config.json
# start balancer server
bin/slb -strategy <round_robin or least_busy> -config config.json
# start the requester (only for demo)
A json file is used to specify hosts that are in the node pool, and the port that the load balancer to run on.