Skip to content

Golang HTTP Handler implementation of load balancer algorithms

License

Notifications You must be signed in to change notification settings

jangie/goloadbalancers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goloadbalancers

A couple of go http.Handler middleware implementing various load balancing algorithms. vulcand's oxy does a great job with roundrobin and a dynamic roundrobin, and also a request proxy mechanism, so do take a look at that repository as well.

To play with the toy test server:

  • Get glide (https://github.com/Masterminds/glide) on your local
  • glide install
  • go test `go list ./... | grep -v vendor`
  • go build
  • Set your hosts file to include testa, testb, testc, pointing at your localhost
  • ./goloadbalancers
  • [separate terminal] node testServer.js

##random Choose randomly between a set of balancees.

##jsq (JoinShortestQueue) Choose from balancees the balancee with the currently lowest number of outstanding requests.

##bestof After I attended a talk given by Tyler McMullen (it appears a video of another rendition of it is here) I was inspired to write this bit of software up. The talk mentioned this paper which apparently advocates a modified Least Connections/Join Shortest queue algorithm, where, instead of blindly choosing the server with the least outstanding connections, instead there is a configured number of choices of random servers, of which are compared the number of outstanding connections.

This helps smooth out the potential for the 'finger of death', whereby in a standard JSQ implementation, a server newly joining (due to newly happy health check or growth of the load balancees) the load balancer will suddenly receive all requests to 'catch it up' to the rest of the servers; this has the potential to fully tank the newly happy server. This is because it is more likely than 0% that the new server will not be chosen, and that an existing server will be taking the load.

The implementation is done such that a golang consumer which can deal with an http.Handler will be able to balance between several specified balancees.

About

Golang HTTP Handler implementation of load balancer algorithms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published