{"id":26800394,"url":"https://github.com/rahul07bagul/design-load-balancer","last_synced_at":"2026-04-28T20:05:39.241Z","repository":{"id":284634351,"uuid":"935727300","full_name":"rahul07bagul/Design-Load-Balancer","owner":"rahul07bagul","description":"Load Balancer System using C++ and gRPC.","archived":false,"fork":false,"pushed_at":"2025-03-26T21:27:55.000Z","size":1214,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T22:28:36.899Z","etag":null,"topics":["cpp","design-patterns","grpc","load-balancer","multithreading","server","system-design"],"latest_commit_sha":null,"homepage":"","language":"C++","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/rahul07bagul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2025-02-19T23:18:26.000Z","updated_at":"2025-03-26T21:28:13.000Z","dependencies_parsed_at":"2025-03-26T22:38:55.608Z","dependency_job_id":null,"html_url":"https://github.com/rahul07bagul/Design-Load-Balancer","commit_stats":null,"previous_names":["rahul07bagul/load-balancer-cpp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul07bagul%2FDesign-Load-Balancer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul07bagul%2FDesign-Load-Balancer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul07bagul%2FDesign-Load-Balancer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul07bagul%2FDesign-Load-Balancer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rahul07bagul","download_url":"https://codeload.github.com/rahul07bagul/Design-Load-Balancer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246237437,"owners_count":20745348,"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":["cpp","design-patterns","grpc","load-balancer","multithreading","server","system-design"],"created_at":"2025-03-29T20:17:01.874Z","updated_at":"2026-04-28T20:05:39.236Z","avatar_url":"https://github.com/rahul07bagul.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Design Load Balancer (C++)\n\n## Overview\nThis project implements a Load Balancer System for managing backend servers efficiently. It supports automatic server scaling, health checking, and request distribution using a Round-Robin, Least Connection, Resource Based Strategy. The system is built using C++ with gRPC for inter-service communication and Crow for HTTP-based management.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/c++-%2300599C.svg?style=for-the-badge\u0026logo=c%2B%2B\u0026logoColor=white\" alt=\"C++\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/CMake-%23008FBA.svg?style=for-the-badge\u0026logo=cmake\u0026logoColor=white\" alt=\"CMake\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Windows-0078D6?style=for-the-badge\u0026logo=windows\u0026logoColor=white\" alt=\"Windows\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Linux-FCC624?style=for-the-badge\u0026logo=linux\u0026logoColor=black\" alt=\"Linux\"\u003e\n\u003c/p\u003e\n\n## Features\n- Load Balancing: Distributes incoming requests among active backend servers.\n- Server Management: Allows dynamic addition and removal of backend servers.\n- Health Monitoring: Periodically checks server health and replaces unhealthy instances.\n  - Scale Up: Adds a new server if CPU usage exceeds 80%\n  - Failure Handling: Adds a new server if an existing one is unresponsive.\n  - Scale Down: Removes servers when they are no longer needed to optimize resource usage.\n- Admin API: Provides gRPC-based server administration.\n- HTTP API: Enables interaction with the system using RESTful endpoints.\n\n## Design Patterns\n- Strategy Pattern: Supports different load-balancing algorithms (e.g., Round-Robin) that can be easily added or configured, making the system scalable.\n- Factory Pattern: Provides an abstraction for OS-specific process management, enabling support for both Windows and Linux to create, terminate processes, and retrieve resource details.\n\n## Demo\n![Design](https://github.com/rahul07bagul/load-balancer-cpp/blob/main/images/img1.png)\n\n## Architecture\n![Design](https://github.com/rahul07bagul/load-balancer-cpp/blob/main/images/Load%20Balancer.png)\n\n## Class Diagram\n![Design](https://github.com/rahul07bagul/load-balancer-cpp/blob/main/images/Design.png)\n\n## Installation \u0026 Setup\n### Prerequisites\n- C++17 or later\n- gRPC and Protobuf\n- Crow HTTP frameowrk\n- CMake\n- [Click here to view instructions.txt](https://github.com/rahul07bagul/load-balancer-cpp/blob/main/instructions.txt)\n### Package Installation\n- Download vcpkg\n```shell\ngit clone https://github.com/Microsoft/vcpkg.git\ncd vcpkg\n.\\bootstrap-vcpkg.bat\n```\n- Install gRPC and protobuf\n```shell\n.\\vcpkg install grpc:x64-windows\n.\\vcpkg install protobuf:x64-windows\n.\\vcpkg integrate install\n```\n### Running the Load Balancer\n```shell\n./load_balancer --backend-path ./server --port 50050 --min-servers 2 --max-servers 5 --start-port 50051\n```\n### Running the Health Checker\n```shell\n./health_checker 127.0.0.1:50050\n```\n\n## API Endpoints\n### HTTP API (Crow)\n- GET /api/status - Returns a list of active servers.\n- POST /api/add_server - Adds a new backend server.\n- POST /api/remove_server - Removes a server by ID.\n\n## Contributing\nFeel free to contribute by submitting pull requests or feature requests.\n\n## Demo Images\n![Design](https://github.com/rahul07bagul/load-balancer-cpp/blob/main/images/img2.png)\n![Design](https://github.com/rahul07bagul/load-balancer-cpp/blob/main/images/img3.png)\n  \n\n\n\n\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahul07bagul%2Fdesign-load-balancer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahul07bagul%2Fdesign-load-balancer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahul07bagul%2Fdesign-load-balancer/lists"}