Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hakobe/grpc-go-client-side-load-balancing-example
This is a gRPC client-side load balancing example on top of grpc-go.
https://github.com/hakobe/grpc-go-client-side-load-balancing-example
Last synced: 8 days ago
JSON representation
This is a gRPC client-side load balancing example on top of grpc-go.
- Host: GitHub
- URL: https://github.com/hakobe/grpc-go-client-side-load-balancing-example
- Owner: hakobe
- License: mit
- Created: 2018-04-08T14:51:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-08-30T02:52:21.000Z (about 3 years ago)
- Last Synced: 2024-06-20T02:10:08.181Z (5 months ago)
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 16
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gRPC client side load balancing example using Go
This is a gRPC client-side load balancing example on top of [grpc-go](https://github.com/grpc/grpc-go).
The only load balancer bundled to grpc-go is `grpc.RoundRobin`. grpc RoundRoubin requires a `grpc.Resolver` which is intended to implement a DNS resolver or an other resourse resolution mechanism like Consul.
In this example I implemented a `grpc.Resolver` which only returns fixed servers initially passed. It is good for trying gRPC load balancing instantly.
## Prequirements
- [protoc](https://github.com/google/protobuf)
- [protoc-gen-go](https://github.com/golang/protobuf/tree/master/protoc-gen-go)
- `$ go get -u github.com/golang/protobuf/protoc-gen-go`## Build
```
$ make
```## Run
```console
# Run 4 servers
$ ./server/server -hostport 0.0.0.0:5000 &
$ ./server/server -hostport 0.0.0.0:5001 &
$ ./server/server -hostport 0.0.0.0:5002 &
$ ./server/server -hostport 0.0.0.0:5003 &$ sleep 3 # Wait for server to start up
# Do gRPC method calls 10000 times
$ time ./client/client -n 10000 \
-server localhost:5000 \
-server localhost:5001 \
-server localhost:5002 \
-server localhost:5003 \
# or
$ ./run.sh
```# LICENSE
MIT @hakobe