非常简单的分布式异步rpc server实现 依赖etcd做服务发现
- 添加了grpc的实现
- 添加了v4客户端,类似stream?
- 添加了v5客户端,链接池
- 添加了grpc+k8s的实现,包括dockerfile、k8s配置等
造轮子使我快乐
- Download and install it:
$ go get -u github.com/Ninlgde/rpc_go
- Import it in your code:
import "github.com/Ninlgde/rpc_go/v3.0"
-
start etcd
- docker
sudo docker run -p 2379:2379 -v /etc/ssl/certs/:/etc/ssl/certs/ elcolio/etcd
- macos
brew install etcd etcd
-
start server
go run server_v3_main.go -port=8080 go run server_v3_main.go -port=8081 go run server_v3_main.go -port=8082 go run server_vgrpc_main.go -port=18080 go run server_vgrpc_main.go -port=18081 go run server_vgrpc_main.go -port=18082
-
start http aip server
go run http_api_server.go
-
go and test
-
benchmark
- wrk install
git clone https://github.com/wg/wrk
make & make install
- go and test
wrk -t144 -c3000 -d30s -T30s --latency http://127.0.0.1:8888/v4/pi/10000 wrk -t144 -c3000 -d30s -T30s --latency http://127.0.0.1:8888/v5/pi/10000 wrk -t144 -c3000 -d30s -T30s --latency http://127.0.0.1:8888/vgrpc/pi/10000
run rpc server on minikube
fork from: https://github.com/tinrab/kubernetes-go-grpc-tutorial.git
-
cd k8s
cd k8s
-
build pb
protoc -I . --go_out=plugins=grpc:./pb ./pb/*.proto
-
build docker file
docker build -t local/service -f Dockerfile.service . docker build -t local/apis -f Dockerfile.apis .
-
apply yaml
kubectl apply -f calc.yaml kubectl apply -f api.yaml
-
test
curl $(minikube service api-service --url)/ping/hello curl $(minikube service api-service --url)/pi/20000 curl $(minikube service api-service --url)/gcd/333/653
-
api server的错误码
-
灰度发布
-
心跳