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

多个Servant可以共享同一套IP端口吗? #87

Closed
chenyahui opened this issue Dec 1, 2018 · 4 comments
Closed

多个Servant可以共享同一套IP端口吗? #87

chenyahui opened this issue Dec 1, 2018 · 4 comments
Labels
question Further information is requested

Comments

@chenyahui
Copy link

Tars中每个Servant似乎都是独立的IP和端口。如果想把服务接口分割成多个Servant,每个Servant负责少量的服务接口。这样的话似乎并不是太友好。

多个Servant可以共享同一套IP端口吗?

@jyuan68
Copy link
Contributor

jyuan68 commented Dec 1, 2018

看代码是可以的,最终Server都缓存在一个map中的,所以不同名字应该是可以的。
var goSvrs map[string]*transport.TarsServer
var httpSvrs map[string]*http.Server

@glymehrvrd
Copy link

glymehrvrd commented Dec 2, 2018

应该不可以,底层是根据port对servant进行路由的,另外也没有使用socket的reuseaddr,所以不能对同一个端口进行多次listen

@sandyskies sandyskies added the question Further information is requested label Dec 2, 2018
@jyuan68
Copy link
Contributor

jyuan68 commented Dec 6, 2018

看了TarsGo源码,不同Servant不能同享同一IP,假如协议是tcp:那么底层是每个Servant专门开启一个.netListenTCP

@sandyskies
Copy link
Contributor

不行的,servant是用来寻址IP 和port的

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

No branches or pull requests

4 participants