Skip to content

A toy Loadbalancer that I built to better understand how Loadbalancers and Service Discovery works.

Notifications You must be signed in to change notification settings

humanbeeng/go-lb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Load Balancer

This is a toy loadbalancer that I built to better understand how Loadbalancers and Service Discovery works.

Features

  • RoundRobin Load Distribution
  • Registration and Deregistration of backends through Service Discovery
  • Cancellation propogation and timeouts(Configurable duration)
  • Heartbeat and auto-deregistration during backend disconnection
  • Supports all HTTP methods
  • Handles requests concurrently from single and multiple clients

Usage

Start Loadbalancer

$ make run

To enable Service Discovery

  1. Import client library
$ go get github.com/humanbeeng/go-lb/client
  1. Initialise client and pass the loadbalancer's address(lbAddr) and the server's listenaddress(*addr)
conn, _ := net.Dial("tcp", lbAddr)
c := client.Client{Conn: conn, Addr: *addr}
c.Register()

TODO:

  • URL pattern matched balancing
  • Configurable strategy
  • Hot reload config changes
  • Export metrics about healthy servers
  • CLI to add and remove backends and change strategy in realtime

About

A toy Loadbalancer that I built to better understand how Loadbalancers and Service Discovery works.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published