Skip to content

RuningRabbit/tinybalancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinybalancer

Go Report Card GitHub top language GitHub stars GitHub forks GitHub codecov  go_version

tinybalancer is a reverse proxy load balancer that supports http and https. It currently supports five algorithms, namely round-robin, random, the power of 2 random choice, consistent hash and consistent hash with bounded.

Install

First download the source code of balancer:

> git clone https://github.com/zehuamama/tinybalancer.git

compile the source code:

> cd ./tinybalancer

> go build

Run

Balancer needs to configure the config.yaml file, the content is as follows:

# Copyright 2022 <mzh.scnu@qq.com>. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.


# The load balancing algorithms supported by the balancer are:
# `round-robin` ,`random` ,`p2c`,`consistent-hash`,`bounded`,
# Among these,`p2c` refers to the power of 2 random choice,
# and `bounded` refers to consistent hash with bounded

schema: http                      # support http and https
port: 8089                        # port for balancer
ssl_certificate:
ssl_certificate_key:
location:                         # route matching for reverse proxy
  - pattern: /
    proxy_pass:                   # URL of the reverse proxy
    - "http://127.0.0.1:1012"
    - "http://127.0.0.1:1013"
    balance_mode: round-robin     # load balancing algorithm

and now, you can execute tinybalancer, the balancer will print the ascii diagram and configuration details:

> ./tinybalancer

___ _ _  _ _   _ ___  ____ _    ____ _  _ ____ ____ ____ 
 |  | |\ |  \_/  |__] |__| |    |__| |\ | |    |___ |__/ 
 |  | | \|   |   |__] |  | |___ |  | | \| |___ |___ |  \                                        

Schema: http
Port: 8089
Location:
	Route: /
	ProxyPass: [http://127.0.0.1:1012 http://127.0.0.1:1013]
	Mode: round-robin

About

πŸŽ‰ Fast, stable load balancer that supports http and https

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages