Skip to content

A lightweight and containerized HTTP Load Balancer built in Go that distributes client requests across multiple NGINX backend servers using a round-robin algorithm. Designed for learning and experimentation, this project showcases how to implement basic load balancing logic in Go and orchestrate services using Docker Compose.

Notifications You must be signed in to change notification settings

PranavTrip/Go-Load-Balancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-Load-Balancer

A simple round-robin load balancer written in Go that proxies HTTP requests across multiple backend NGINX servers using Docker Compose.


📦 Stack

  • 🧠 Go – Custom load balancer using httputil.ReverseProxy
  • 🌐 NGINX – Lightweight HTTP servers as backends
  • 🐳 Docker Compose – Orchestration of all services

⚙️ Architecture

       ┌────────────┐
       │  Client    │
       └────┬───────┘
            │
     ┌──────▼────────┐
     │ Go LoadBalancer│
     └────┬────┬─────┘
          │    │
 ┌────────▼┐ ┌─▼────────┐
 │ NGINX 1 │ │ NGINX 2  │
 └─────────┘ └──────────┘

Each request is forwarded to the next NGINX container in a round-robin fashion.


🚀 Getting Started

1. Clone the Repository

git clone https://github.com/PranavTrip/Go-Load-Balancer.git
cd Go-Load-Balancer

2. Ensure these folders exist and contain

nginx1/index.html    # "Hello from Server 1"
nginx2/index.html    # "Hello from Server 2"
nginx3/index.html    # "Hello from Server 3"

3. Create them if needed

mkdir -p nginx1 nginx2 nginx3
echo "<h1>Hello from Server 1</h1>" > nginx1/index.html
echo "<h1>Hello from Server 2</h1>" > nginx2/index.html
echo "<h1>Hello from Server 3</h1>" > nginx3/index.html

4. Run Everything

docker-compose up --build

About

A lightweight and containerized HTTP Load Balancer built in Go that distributes client requests across multiple NGINX backend servers using a round-robin algorithm. Designed for learning and experimentation, this project showcases how to implement basic load balancing logic in Go and orchestrate services using Docker Compose.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published