Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chtnnh/loadbalancer
Very simple (bad) implementation of a load balancer in Go
https://github.com/chtnnh/loadbalancer
go golang load-balancer
Last synced: about 2 months ago
JSON representation
Very simple (bad) implementation of a load balancer in Go
- Host: GitHub
- URL: https://github.com/chtnnh/loadbalancer
- Owner: chtnnh
- Created: 2023-06-20T19:47:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-21T16:56:52.000Z (over 1 year ago)
- Last Synced: 2024-04-01T05:46:53.096Z (9 months ago)
- Topics: go, golang, load-balancer
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Load Balancer in Go
## About
A simple implementation in Go to better understand the working of a load balancer.## Usage
Open up your terminal and run the following:
```bash
go run .
```In another terminal window:
```bash
for i in {1..6}
do
curl http://localhost:8000
done
```### Configuration
The `config.json` file looks something like this:
```json
{
"lb": {
"host": "localhost",
"port": 8000
},
"servers": [
{
"host": "localhost",
"port": 8001,
"weight": 3,
"uri": "http://localhost:8001"
},
{
"host": "localhost",
"port": 8002,
"weight": 2,
"uri": "http://localhost:8002"
},
{
"host": "localhost",
"port": 8003,
"weight": 1,
"uri": "http://localhost:8003"
}
],
"protocol": 0
}
```#### Protocols
0: Weighted Round Robin (Just specify weight = 1 to all servers for Round Robin)### Testing
To test the load balancer for race conditions:
```bash
go test -race
```## TODO
1. Support for all methods (currently supports only GET & POST)
2. Dynamic Load Balancing algorithms## Author
Chaitanya Mittal, 2023