ardatosun / loadbalancer

Simple Go Load Balancer
MIT License
5 stars 4 forks source link
hacktoberfest hacktoberfest-accepted

Hacktoberfest 2024 Hacktoberfest

Ccontributions from all levels of experience are welcome! To contribute:

Be sure to read the contribution guidelines and code of conduct before submitting your PR.

Simple Go Load Balancer

This project demonstrates a basic load balancer implemented in Go. It only uses the standard http library.

It uses Docker and Docker Compose to spin up multiple backend HTTP servers and a load balancer that distributes incoming requests among these backends in round-robin fashion.

Features

Getting Started

Prerequisites

Running the Load Balancer

  1. Build and start the containers:

    docker compose up --build
  2. Test the Load Balancer:

    curl http://localhost:8080

    You should see responses from different backend servers (e.g. Hello from backend running on port 80)

  3. Configuring health check Set enviornment variable: export HEALTH_CHECK_INTERVAL=60 (macOS/Linux), set HEALTH_CHECK_INTERVAL=60 (Windows Command Prompt)

Inspired by build-your-own-x repo