{"id":50491458,"url":"https://github.com/bashbunni/load-balancer","last_synced_at":"2026-06-02T03:04:35.295Z","repository":{"id":356388921,"uuid":"1230232568","full_name":"bashbunni/load-balancer","owner":"bashbunni","description":"a basic load balancer to practice rust and get a deeper understanding of load balancers","archived":false,"fork":false,"pushed_at":"2026-05-07T20:11:06.000Z","size":9,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-07T22:16:51.030Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bashbunni.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-05T20:01:11.000Z","updated_at":"2026-05-07T22:11:37.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bashbunni/load-balancer","commit_stats":null,"previous_names":["bashbunni/load-balancer"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/bashbunni/load-balancer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashbunni%2Fload-balancer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashbunni%2Fload-balancer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashbunni%2Fload-balancer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashbunni%2Fload-balancer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bashbunni","download_url":"https://codeload.github.com/bashbunni/load-balancer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashbunni%2Fload-balancer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33803750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-06-02T03:04:30.870Z","updated_at":"2026-06-02T03:04:35.290Z","avatar_url":"https://github.com/bashbunni.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Load Balancer in Rust\n\n## Purpose\nThis repo exists for me to deeply understand load balancers and practice rust development.\n\n## What is a load balancer\nDistributing computational workloads between two or more computers. RE: Internet this is commonly used as a traffic controller for multi-server setups.\n\nWithout load balancing, servers get overloaded. With load balancing, connections are distributed based on the chosen algorithms.\n\n### Logistics\nCan run on a server OR VM OR cloud. CDNs typically provide load balancing features. In this case, I'm using nginx running in a Docker container to test connections.\n\n### Where Can We Find Load Balancers\n- used WITH web apps; redistribute incoming traffic to servers hosting the app\n- also LARGE localized networks; e.g. data center or office complex. These typically require a hardware appliance like an application delivery controller. Though you can also use a software-based load balancer.\n\n### Common Algorithms for Load Balancing\n#### Static (the unbothered king load balancer algorithms)\n- quick to set up\n- ! interest in current server states\n- predetermined\n\n#### Dynamic (FPS game healer)\nTakes into account: current availability, workload, and health of ea. server\n\nDynamic servers are more difficult to configure as they require additional server monitoring. If a server is unavailable, the load balancers with failover to another server/group of server. This happens quickly to avoid any gaps in service.\n\n##### What is availability\n- health + capacity of the server\n- size of tasks distributed\n\n## Steps\n### Most Basic Solution (Level 0)\n- [] create a basic server (L4: TCP) that can start\n- [] receive connection requests\n- [] choose a load balancing algo to redirect traffic to our set of available servers: red robin (until you hit max_cap then switch algo to per service volume)\n- [] health checks: AKA intermittent requests sent to servers to check that they're up and running\n- [] yaml file with available servers; only on startup\n\n### Level 1\n- [] failure handling: do we retry if connection to server fails. Also mark as bad connection\n- [] max number of in-progress requests per backend\n- [] count no of connections for ea server\n- [] graceful shutdown (no more connections, wrap up existing requests)\n\n## Choosing an Algorithm\nStep 1. We start with static. The goal here is to get an idea of the simplest possible configuration. Then when we move on to dynamic load balancers, we have a frame of reference meaning we can better assess the tradeoffs.\n\n### Static\n- round robin: in-order distribution\n- weighted round robin: round robin + ea. server has a \"power value\" to dictate its capabilities. (e.g. server B is 3x faster than server A, it receives 3x more requests)\n- source IP hash: get hash of client IP -\u003e stores it so all requests from that IP go to the same server. Likely mostly for an entire country for example\n(chat says this is not how hashes work...)\n- random\n\n### Dynamic\n- least connections: (*most used*) go to server with fewest active connections\n- least response time: prioritizes servers by fastest response times (historical data)\n- weighted least response time: LRT + server capacity weights (power)\n- resource-based: real-time CPU, memory, disk I/O status for servers to avoid overload.\n\n## Development\n\nTo pretend we have servers to connect to use an nginx docker container `docker run -d -p 43003:80 nginx`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashbunni%2Fload-balancer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbashbunni%2Fload-balancer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashbunni%2Fload-balancer/lists"}