https://github.com/alfredoprograma/basic-load-balancing
Basic load balancing setup case study
https://github.com/alfredoprograma/basic-load-balancing
Last synced: 5 months ago
JSON representation
Basic load balancing setup case study
- Host: GitHub
- URL: https://github.com/alfredoprograma/basic-load-balancing
- Owner: AlfredoPrograma
- Created: 2025-06-30T01:51:29.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-30T01:52:18.000Z (12 months ago)
- Last Synced: 2025-08-14T02:24:00.330Z (11 months ago)
- Language: Dockerfile
- Size: 2.93 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Study Case: Basic Load Balancing
This study case dives into the basics of load balancing using Nginx and a Go-based backend. It demonstrates how requests can be distributed across multiple backend instances to improve scalability and reliability.
## Objectives
- Learn the fundamentals of load balancing in distributed systems.
- Set up Nginx as a load balancer.
- Use Docker and Docker Compose for containerized deployments.
- Observe how a simple Go-based backend API behaves under load balancing.
## Project Structure
- `main.go`: Go code for the backend API.
- `Dockerfile`: Docker image definition for the backend API.
- `docker-compose.yml`: Configuration for the backend services and Nginx load balancer.
- `nginx.conf`: Nginx configuration file.
- `go.mod`: Go module file.
## Getting Started
1. Make sure Docker and Docker Compose are installed.
2. Start the services with:
```bash
docker-compose up
```
3. Open your browser and go to `http://localhost:8080` to interact with the load balancer.
## Backend API
The backend API is a simple Go application that responds with "Hello world!" to GET requests at the root endpoint (`/`).
## Load Balancer
Nginx acts as the load balancer, routing incoming requests to one of the backend API instances (`api1`, `api2`, `api3`).
It also adds a custom header `X-Upstream-Addr` to show which backend instance handled the request.