Skip to content

thisisnitish/n-load-balancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Load Balancer

A simple HTTP load balancer implemented in Go with round-robin distribution and automatic health checking.

Features

  • Round-robin load balancing across multiple backend servers
  • Automatic health checks (every 10 seconds)
  • Instant failure detection and retry on next available backend
  • Graceful handling when backends go down/come back up

Usage

go run main.go

The load balancer starts on port 8080 and distributes traffic to backends defined in main.go.

Testing

Start test backend servers:

cd testserver && go run main.go 8081
cd testserver && go run main.go 8082
cd testserver && go run main.go 8083

Send requests:

curl http://localhost:8080

How It Works

  1. Receives incoming requests on port 8080
  2. Selects next healthy backend using round-robin algorithm
  3. Proxies request to selected backend
  4. If backend fails, immediately tries next available backend
  5. Health checks run every 10 seconds to detect recovered backends

About

Load Balancer implementation in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages