chenBright commented on issue #2143: URL: https://github.com/apache/brpc/issues/2143#issuecomment-1452920351
> > 如下例子,当Channel和Controller是service回调函数的栈变量,且ns需要通过rpc获取节点信息时 > > 感觉这个使用场景不是很合理,如果Channel是service回调函数的栈变量,那么每处理一个请求都需要创建/销毁一次Channel,而且这个过程中还会查询ns,而ns还需要rpc来获取节点信息,这样每次请求都要查一次ns,很低效。 > > 通常来说如果每次请求动态创建Channel,一般Channel都是比较轻量的,比如SingleServer模式,或者list ns。对于比较重的ns最好还是做成全局一个Channel的这种使用方式。 这个场景不是很合理,但是Channel并没有限制这种用法。像Consul ns的rpc第一次获取节点信息是很快的,但是后续就是long polling,没有变更的话,consul不会返回,ns的rpc等到超时才能结束。这时候Channel析构就是存在等的问题了。 还是说,在实现ns的时候,需要考虑这个问题。实现ns的时候,不能在GetServers里发起rpc调用,而是实现一个ns client去查ns,GetServers则是去查ns client的缓存。但是这样会有一个问题,每个ns对应的协程数由1个变成了2个了。 主要是想看能不能从框架层面规避这个问题。 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
