{"id":16230604,"url":"https://github.com/wanzo-mini/mini-balancer","last_synced_at":"2025-10-25T00:31:34.028Z","repository":{"id":40245979,"uuid":"485029497","full_name":"wanzo-mini/mini-balancer","owner":"wanzo-mini","description":"🎉 A go library that implements load balancing algorithms. Fast, stable mini layer 7 load balancer. ","archived":true,"fork":false,"pushed_at":"2025-01-24T14:32:12.000Z","size":69,"stargazers_count":560,"open_issues_count":0,"forks_count":84,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-01-25T07:47:04.872Z","etag":null,"topics":["go","proxy","reverse-proxy"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wanzo-mini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2022-04-24T13:05:11.000Z","updated_at":"2025-01-24T14:34:49.000Z","dependencies_parsed_at":"2023-07-13T05:15:22.064Z","dependency_job_id":"b23efcfc-e131-48ae-91b9-3d5930d9e487","html_url":"https://github.com/wanzo-mini/mini-balancer","commit_stats":null,"previous_names":["zehuamama/tinybalancer","wanzoma/balancer","hyman-m/balancer","zehuamama/balancer","wanzo-mini/mini-balancer"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanzo-mini%2Fmini-balancer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanzo-mini%2Fmini-balancer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanzo-mini%2Fmini-balancer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanzo-mini%2Fmini-balancer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wanzo-mini","download_url":"https://codeload.github.com/wanzo-mini/mini-balancer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238053514,"owners_count":19408699,"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","proxy","reverse-proxy"],"created_at":"2024-10-10T13:01:06.598Z","updated_at":"2025-10-25T00:31:28.750Z","avatar_url":"https://github.com/wanzo-mini.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# mini-balancer\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/wanzo-mini/mini-balancer)](https://goreportcard.com/report/github.com/wanzo-mini/mini-balancer)\u0026nbsp;![GitHub top language](https://img.shields.io/github/languages/top/wanzo-mini/mini-balancer)\u0026nbsp;![GitHub](https://img.shields.io/github/license/wanzo-mini/mini-balancer)\u0026nbsp;[![CodeFactor](https://www.codefactor.io/repository/github/wanzo-mini/mini-balancer/badge)](https://www.codefactor.io/repository/github/wanzo-mini/mini-balancer)\u0026nbsp;[![codecov](https://codecov.io/gh/wanzo-mini/mini-balancer/branch/main/graph/badge.svg)](https://codecov.io/gh/wanzo-mini/mini-balancer)\u0026nbsp; ![go_version](https://img.shields.io/badge/go%20version-1.17-yellow)\n\n`mini-balancer` is a layer 7 load mini-balancer that supports http and https, and it is also a go library that implements `load balancing` algorithms.\n\nIt currently supports load balancing algorithms: \n* `round-robin`\n* `random`\n* `power of 2 random choice`\n* `consistent hash`\n* `consistent hash with bounded`\n* `ip-hash`\n* `least-load`\n\n## Install\nFirst download the source code of mini-balancer:\n```shell\n\u003e git clone https://github.com/wanzo-mini/mini-balancer.git\n```\ncompile the source code:\n```shell\n\u003e cd ./mini-balancer\n\n\u003e go build\n```\n\n## Run\n`mini-balancer` needs to configure the `config.yaml` file, see [config.yaml](https://github.com/wanzo-mini/mini-balancer/blob/main/config.yaml) :\n\nand now, you can execute `mini-balancer`, the mini-balancer will print the ascii diagram and configuration details:\n```shell\n\u003e ./mini-balancer\n\n___ _ _  _ _   _ ___  ____ _    ____ _  _ ____ ____ ____ \n |  | |\\ |  \\_/  |__] |__| |    |__| |\\ | |    |___ |__/ \n |  | | \\|   |   |__] |  | |___ |  | | \\| |___ |___ |  \\                                        \n\nSchema: http\nPort: 8089\nHealth Check: true\nLocation:\n        Route: /\n        Proxy Pass: [http://192.168.1.1 http://192.168.1.2:1015 https://192.168.1.2 http://my-server.com]\n        Mode: round-robin\n\n```\n`mini-balancer` will perform `health check` on all proxy sites periodically. When the site is unreachable, it will be removed from the mini-balancer automatically . However, `mini-balancer` will still perform `health check` on unreachable sites. When the site is reachable, it will add it to the mini-balancer automatically.\n\n## API Usage\n`mini-balancer` is also a go library that implements load balancing algorithms, it can be used alone as an API, you need to import it into your project first:\n```shell\n\u003e go get github.com/wanzo-mini/mini-balancer/mini-balancer\n```\n\nBuild the load mini-balancer with `mini-balancer.Build`:\n```go\nhosts := []string{\n\t\"http://192.168.11.101\",\n\t\"http://192.168.11.102\",\n\t\"http://192.168.11.103\",\n\t\"http://192.168.11.104\",\n}\n\nlb, err := mini-balancer.Build(mini-balancer.P2Cmini-balancer, hosts)\nif err != nil {\n\treturn err\n}\n```\nand you can use mini-balancer like this:\n```go\n\nclientAddr := \"172.160.1.5\"  // request IP\n\t\ntargetHost, err := lb.Balance(clientAddr) \nif err != nil {\n\tlog.Fatal(err)\n}\n\t\nlb.Inc(targetHost)\ndefer lb.Done(targetHost)\n\n// route to target host\n```\neach load mini-balancer implements the `mini-balancer.mini-balancer` interface:\n```go\ntype mini-balancer interface {\n\tAdd(string)\n\tRemove(string)\n\tBalance(string) (string, error)\n\tInc(string)\n\tDone(string)\n}\n```\ncurrently supports the following load balancing algorithms:\n```go\nconst (\n\tIPHashmini-balancer         = \"ip-hash\"\n\tConsistentHashmini-balancer = \"consistent-hash\"\n\tP2Cmini-balancer            = \"p2c\"\n\tRandommini-balancer         = \"random\"\n\tR2mini-balancer             = \"round-robin\"\n\tLeastLoadmini-balancer      = \"least-load\"\n\tBoundedmini-balancer        = \"bounded\"\n)\n```\n\n\n## Contributing\n\nIf you are interested in contributing to mini-balancer, please see here: [CONTRIBUTING](https://github.com/wanzo-mini/mini-balancer/blob/main/CONTRIBUTING.md)\n\n## License\n\nmini-balancer is licensed under the term of the [BSD 2-Clause License](https://github.com/wanzo-mini/mini-balancer/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanzo-mini%2Fmini-balancer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwanzo-mini%2Fmini-balancer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanzo-mini%2Fmini-balancer/lists"}