GithubHelp home page GithubHelp logo

grpc-lb's Issues

请教一些问题

1.本例子中是网关是只有一个服务的,但是如果我有多个服务,网关的代码应该如何编写,grpc是如何确定要选择那个路由的。

2.这行代码中的第二个参数为什么是"://authority/",有什么含义吗

conn, err := grpc.DialContext(ctx, r.Scheme()+"://authority/"+*svc, grpc.WithInsecure(), grpc.WithBalancerName(roundrobin.Name), grpc.WithBlock())

话说现在包是怎么了。。。

现在etcd包的结构已经混乱了,源码里引用的是go.etcd.io的包,但是这个网站上的包下不下来。这导致github上git下来的代码是乱的,import都找不到
image
现在应该要这样。。。。于是自己创建路径手动移动,建议你把这个写出来提醒一下大家!!很无语的。。

服务下线,其实并未从客户端将命名解析删除

watcher.go
return []*naming.Update{{Op: naming.Delete, Addr: string(ev.Kv.Value)}}, nil
当服务从etcd下线,客户端watch检测到删除事件,但是其实删除事件中并未携带删除的值,只携带了键,所以ev.Kv.Value是一个空字符串。这时候在 google.golang.org/grpc/balancer.go 185L 会与本地的地址列表匹配不上,导致并未执行命名地址列表的删除操作

cli.go里面cancel的作用

在项目 /cmd/cli/cli.go里面有cancel()方法,而且grpc.DialContext也继承了上面创建的上下文,如果提前执行cancel,那grpc的连接不是和上面那个上下文一样就会被cancel取消吗,不知道放在这里的作用是什么,是不是defer cancel()更好

KeepAlive方法性能问题

	if _, err := cli.KeepAlive(context.TODO(), resp.ID); err != nil {
		return fmt.Errorf("grpclb: refresh service '%s' with ttl to clientv3 failed: %s", service, err.Error())
	}

cli.KeepAlive返回的<-chan *LeaseKeepAliveResponse 没有消费,会一直发送keep alive requests,虽然不影响功能但是影响性能

请教一个别的问题

你好,刚刚接触 grpc的lb,不能理解在client端做负载均衡的设计,按照你的demo,比如我现在有10个服务节点,10000个client,岂不是每个client都要建立10个TCP链接,而每次只用一个链接来请求服务,每个服务端都要有10000个TCP链接,而这10000个链接平均下来只有1/10的链接是活跃的(如果使用轮询的话),这不是很耗费资源么?希望能得到回复哈,十分感谢。

不读取返回的消息是否不妥

if _, err := cli.KeepAlive(context.TODO(), resp.ID); err != nil {

官方文档

// KeepAlive keeps the given lease alive forever. If the keepalive response
// posted to the channel is not consumed immediately, the lease client will
// continue sending keep alive requests to the etcd server at least every
// second until latest response is consumed.
KeepAlive使给定的租约永远活着。
如果发布到通道上的keepalive响应没有立即被消耗,
租赁客户端将继续向etcd服务器发送keep alive请求,
至少每秒钟一次,直到最新的响应被消耗掉。

如果不进行读取,将会以每秒一次的频率进行需约。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.