{"id":27941921,"url":"https://github.com/rishichirchi/load-balancer","last_synced_at":"2025-05-07T11:24:05.765Z","repository":{"id":263228344,"uuid":"880831710","full_name":"rishichirchi/Load-Balancer","owner":"rishichirchi","description":"This project is a custom-built load balancer written in Go. It distributes incoming HTTP requests among multiple backend servers using a round-robin algorithm, with health checks to ensure backends are responsive.","archived":false,"fork":false,"pushed_at":"2024-12-21T18:41:18.000Z","size":4620,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T02:04:32.268Z","etag":null,"topics":["go","golang","http-server","load-balancer","round-robin"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rishichirchi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-30T12:51:26.000Z","updated_at":"2024-12-21T18:41:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"31809572-60f0-4440-a10e-741c567fbbc0","html_url":"https://github.com/rishichirchi/Load-Balancer","commit_stats":null,"previous_names":["rishichirchi/load-balancer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishichirchi%2FLoad-Balancer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishichirchi%2FLoad-Balancer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishichirchi%2FLoad-Balancer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishichirchi%2FLoad-Balancer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rishichirchi","download_url":"https://codeload.github.com/rishichirchi/Load-Balancer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252866787,"owners_count":21816542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","http-server","load-balancer","round-robin"],"created_at":"2025-05-07T11:24:05.092Z","updated_at":"2025-05-07T11:24:05.743Z","avatar_url":"https://github.com/rishichirchi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Load Balancer Project\n\nThis repository contains a load balancer implementation in Go along with a basic backend server. The load balancer distributes incoming requests across multiple backend servers, ensuring efficient resource utilization and fault tolerance.\n\n## Folder Structure\n\n```\nrepo/\n |- backend/\n |   |- backend.go\n |- load-balancer/\n     |- load-balancer.go\n```\n\n### File Descriptions\n\n1. **`backend/backend.go`**:\n   - A simple HTTP server that listens on a specified port.\n   - It responds with a message indicating that the backend server is running.\n\n2. **`load-balancer/load-balancer.go`**:\n   - The core load balancer implementation.\n   - Distributes requests among multiple backend servers using a round-robin algorithm.\n   - Performs health checks to ensure backend servers are available.\n\n---\n\n## Features\n\n- **Round-Robin Load Balancing**: Ensures an even distribution of requests across backend servers.\n- **Health Checks**: Periodically verifies the availability of backend servers.\n- **Retries**: Automatically retries requests if a backend server fails.\n- **Dynamic Configuration**: Backends can be configured via command-line arguments.\n\n---\n\n## Setup and Usage\n\n### Prerequisites\n- Go installed on your system (version 1.16+).\n\n### Steps to Run\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/rishichirchi/Load-Balancee\n   cd repo\n   ```\n\n2. Build and run the backend servers:\n   ```bash\n   cd backend\n   go build -o backend-server backend.go\n   PORT=8081 ./backend-server \u0026\n   PORT=8082 ./backend-server \u0026\n   ```\n\n3. Build and run the load balancer:\n   ```bash\n   cd ../load-balancer\n   go build -o load-balancer load-balancer.go\n   ./load-balancer -backends=http://localhost:8081,http://localhost:8082 -port=3030\n   ```\n\n4. Access the load balancer:\n   Open your browser and navigate to `http://localhost:3030`. The requests will be distributed across the backend servers.\n\n---\n\n## Workflow Diagram\n\nBelow is a simplified workflow of the Load Balancer system:\n\n```mermaid\ngraph TD\n    A[Client Request] --\u003e|HTTP Request| B[Load Balancer]\n    B --\u003e|Round-Robin| C[Backend 1]\n    B --\u003e|Round-Robin| D[Backend 2]\n    C --\u003e|Response| A\n    D --\u003e|Response| A\n    B --\u003e|Health Check| E[Monitor Backends]\n```\n\n---\n\n## Configuration\n\n### Command-Line Flags\n\n- `-backends`: Comma-separated list of backend server URLs (e.g., `http://localhost:8081,http://localhost:8082`).\n- `-port`: Port for the load balancer to listen on (default: `3030`).\n\n---\n\n## Example Logs\n\n```plaintext\n2024/12/21 12:00:00 Configured server: http://localhost:8081\n2024/12/21 12:00:00 Configured server: http://localhost:8082\n2024/12/21 12:00:01 Load balancer started at :3030\n2024/12/21 12:01:00 Selected backend: http://localhost:8081\n2024/12/21 12:01:05 Selected backend: http://localhost:8082\n2024/12/21 12:02:00 Starting health check...\n2024/12/21 12:02:00 http://localhost:8081 [up]\n2024/12/21 12:02:00 http://localhost:8082 [up]\n2024/12/21 12:02:00 Health check completed\n```\n\n---\n\n## Future Improvements\n\n- Add support for weighted load balancing.\n- Implement SSL termination at the load balancer level.\n- Enhance monitoring and alerting for backend server health.\n\n---\n\n## License\nThis project is licensed under the MIT License.\n\n---\n\n## Contributing\nFeel free to open issues or submit pull requests for improvements or bug fixes.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frishichirchi%2Fload-balancer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frishichirchi%2Fload-balancer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frishichirchi%2Fload-balancer/lists"}