Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brpc可以支持预连接吗 #2617

Open
yzq-del opened this issue Apr 26, 2024 · 5 comments
Open

brpc可以支持预连接吗 #2617

yzq-del opened this issue Apr 26, 2024 · 5 comments

Comments

@yzq-del
Copy link

yzq-del commented Apr 26, 2024

现在好像是第一次rpc调用时才触发创建链接,第一次调用会慢一点。 可以在channel init时就创建和服务端的链接吗?

@chenBright
Copy link
Contributor

不可行吧。

有些时候,channel是动态创建的,Init之后发起rpc。A->B->C这种场景下,B要等到所有socket建连好才发rpc给C,rpc完成后相应A。这时候第一次调用的耗时会显著增加,甚至会超时吧。

@yzq-del
Copy link
Author

yzq-del commented Apr 28, 2024

不可行吧。

有些时候,channel是动态创建的,Init之后发起rpc。A->B->C这种场景下,B要等到所有socket建连好才发rpc给C,rpc完成后相应A。这时候第一次调用的耗时会显著增加,甚至会超时吧。

这个也不冲突吧。实现的细节问题,1、做成可选项,使用者自己决定。 2、框架做更细点,连接异步创建,”B要等到所有socket建连好才发rpc给C“这个可以做成”当前有连接成功的,就先用着呗“,且这个说法我有点疑惑,init后马上调用rpc,也需要先创建链接的,他是创建一个链接就马上发,还是等所有链接创建完再发?

@chenBright
Copy link
Contributor

目前Socket不支持预先建连,不过 #2574 实现了在创建Socket对象的时候建连。

@chenBright
Copy link
Contributor

这个说法我有点疑惑,init后马上调用rpc,也需要先创建链接的,他是创建一个链接就马上发,还是等所有链接创建完再发?

https://github.com/apache/brpc/blob/master/docs/cn/client.md#%E9%99%84client%E7%AB%AF%E5%9F%BA%E6%9C%AC%E6%B5%81%E7%A8%8B

可以看看这个流程图。对于使用名字访问的场景,rpc要等到所有Socket对象(只是创建Socket对象,这个过程很快)创建好才会发出去。

@chenBright
Copy link
Contributor

做成可选项,使用者自己决定

嗯,肯定是做成可选项的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants