{"id":18879187,"url":"https://github.com/jackychiu/slb","last_synced_at":"2025-04-14T19:13:38.233Z","repository":{"id":91227833,"uuid":"108613184","full_name":"JackyChiu/slb","owner":"JackyChiu","description":"Simple Load Balancer","archived":false,"fork":false,"pushed_at":"2018-02-28T03:59:38.000Z","size":14614,"stargazers_count":132,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T19:13:30.120Z","etag":null,"topics":["concurrency","golang","load-balancer","pool"],"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/JackyChiu.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":"2017-10-28T02:22:25.000Z","updated_at":"2025-04-11T10:07:43.000Z","dependencies_parsed_at":"2023-06-19T12:38:09.131Z","dependency_job_id":null,"html_url":"https://github.com/JackyChiu/slb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackyChiu%2Fslb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackyChiu%2Fslb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackyChiu%2Fslb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackyChiu%2Fslb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JackyChiu","download_url":"https://codeload.github.com/JackyChiu/slb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248943461,"owners_count":21186958,"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":["concurrency","golang","load-balancer","pool"],"created_at":"2024-11-08T06:34:00.288Z","updated_at":"2025-04-14T19:13:38.208Z","avatar_url":"https://github.com/JackyChiu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Load Balancer [![CircleCI](https://circleci.com/gh/JackyChiu/slb.svg?style=svg)](https://circleci.com/gh/JackyChiu/slb) [![Go Report Card](https://goreportcard.com/badge/github.com/JackyChiu/slb)](https://goreportcard.com/report/github.com/JackyChiu/slb)\n\nslb is a simple single node HTTP load balancer\n\nAvailable strategies are: \n- [Round Robin](round_robin.go)\n- [Least Busy](least_busy.go)\n\nThese strategies for the node pools are also concurrent safe.\n\n## Demo\n### Round Robin\n```bash\nbin/slb -strategy round_robin -config config.json\n```\n![](.github/round_robin.gif)\n\n### Least Busy\n```bash\nbin/slb -strategy least_busy -config config.json\n```\n![](.github/least_busy.gif)\n\nThe pool was tested by a requester that produces tasks at a random interval, faster than the time it takes to complete the requests itself. \nThe tasks also take an inconsistent amount of time to finish.\nIn this example the requests were just sleeps.\n\nThe standard deviation measures how spread out the pending requests are across workers, giving us an idea of how well the pool is distributing work.\nAs time goes by the average load goes up the standard deviation remains about the same!\n\n**Basically the smaller the `Std Dev` the better work is being distributed!**\n\nIt's worth noting that because the requests aren't equal in the amount of work, the round robin balancer's standard deviation starts to climb.\nWhile the least busy strategy keeps the amount of pending tasks in account and results in a better distribution of requests. \n\n## Try The Demo\n```bash\n# clone the project\ngo get github.com/JackyChiu/slb\ncd $GOPATH/src/github.com/JackyChiu/slb\n\n# make project\nmake all\n\n# start local servers (only for demo)\nbin/servers -config config.json\n\n# start balancer server\nbin/slb -strategy \u003cround_robin or least_busy\u003e -config config.json\n\n# start the requester (only for demo)\nbin/requester\n```\n\nA json file is used to specify hosts that are in the node pool, and the port that the load balancer to run on.\n```json\n{\n  \"port\": 8000,\n  \"hosts\": [\n    \"cool-app01.mydomain.com\",\n    \"cool-app02.mydomain.com\",\n    \"cool-app03.mydomain.com\",\n    \"cool-app04.mydomain.com\"\n  ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackychiu%2Fslb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackychiu%2Fslb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackychiu%2Fslb/lists"}