loadBalancer

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2025 License: Apache-2.0

README

LoadBalancer Project

This repository contains a scalable load balancer system implemented in Go, paired with a .NET 9.0 API backend and accompanying load-testing scripts.

Table of Contents


Project Overview

  • API Service: A .NET 9.0 C# Web API that exposes endpoints for user operations, backed by a relational database and EF Core migrations.
  • Load Balancer: A Go-based microservice that distributes incoming requests across healthy API replicas, with auto-scaling logic, Active Monitoring and health checks.
  • Load Testing: JavaScript-based test scripts and HTML/JSON reports to simulate traffic and validate performance.

Prerequisites

Project Structure

loadBalancer/
├── API/                   # .NET 9.0 Web API project
│   ├── Dockerfile         # Builds API container
│   ├── docker-compose.yaml# Defines API + DB services
│   ├── Program.cs
│   ├── API.csproj
│   └── database/          # Connection & EF Core migrations
│       ├── connection.cs
│       └── migration/     # *.cs scripts for schema
├── App/                   # Go load balancer microservice
│   ├── main.go            # Entry point
│   ├── config/            # Global config definitions
│   ├── functions/         # Scaling, health checks, routing
│   ├── structers/         # Data models & heaps
│   └── graphs/Logs        # Latency logs & charting tools
├── Test/                  # Load-testing scripts & results
│   ├── loadtest.js        # k6 JS tests
│   ├── report.html/json   # Generated performance reports
│   └── benchmarks/        # HTML summaries (V1–V7)
├── go.mod
├── go.sum
├── loadBalancer.sln       # Visual Studio solution
├── .gitignore
└── LICENSE

Installation

API Service
  1. Navigate to the API directory:

    cd loadBalancer/API
    
  2. Restore dependencies and build:

    dotnet restore
    dotnet build -c Release
    
Load Balancer (Go App)
  1. Navigate to the App directory:

    cd loadBalancer/App
    
  2. Download dependencies and build:

    go mod tidy
    go build -o loadbalancer
    

Running the Services

By default, when the load balancer starts it will automatically create any missing API service instances and initialize the database.

cd loadBalancer/APP
go run main.go

Load Testing

Use the provided JavaScript load test (loadBalancer/Test/loadtest.js) with k6 or Node.js:

cd loadBalancer/Test
# or if built: ./loadbalancer
k6 run loadtest.js

Review the generated reports in report.html or JSON outputs.

Logs & Metrics

  • Latency logs are written to loadBalancer/App/Logs/latency.log.
  • Charts can be generated via App/graphs/chart_shower.go (requires Go plotting libraries).

Database Migrations

Migration scripts are located in API/database/migration/. To apply:

cd loadBalancer/API
dotnet ef database update

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Contact

Maintained by Belqadi Ayman. Feel free to open issues or reach out via GitHub.

Directories

Path Synopsis
App
Functions
Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.
Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.
config
Package config holds global configuration and runtime state for the load balancer.
Package config holds global configuration and runtime state for the load balancer.
structers
Package structers defines core data structures used by the load balancer.
Package structers defines core data structures used by the load balancer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL