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

gate是否会成为热点? #1

Closed
huahuacn opened this issue Nov 8, 2020 · 10 comments
Closed

gate是否会成为热点? #1

huahuacn opened this issue Nov 8, 2020 · 10 comments

Comments

@huahuacn
Copy link

huahuacn commented Nov 8, 2020

如题,我看到gate既要负责转发来自客户端的消息,还要转发去客户端的消息。会不会成为热点服务,顶不住啊?

@hanxi
Copy link
Owner

hanxi commented Nov 9, 2020

我没有实际压测过,如果真的有性能问题,可以参考 lualib/snax/loginserver.lua 的方式采用 master/slave 的方式分摊压力。

@huahuacn
Copy link
Author

huahuacn commented Nov 9, 2020

嗯嗯,谢谢~

@huahuacn
Copy link
Author

不好意思,再请问一下。在设计上,通过loginserver(https)去验证账号密码,得到一个token。然后通过url/?token=xx的方式来建立ws连接。请问这个token在什么步骤验证是合理的?我目前是握手的时候检查,但是握手的时候好像连接已经建立了。理想的状态是当有新的连接进来时,验证token是否合法,合法才建立连接,不合法直接丢弃。请问在什么位置去验证你有经验或者建议吗?

@hanxi
Copy link
Owner

hanxi commented Nov 19, 2020

建立连接后第一条协议验证token即可,加个定时器超时没发第一个验证协议就踢掉,没验证就发其他协议也踢掉,这样就跟 TCP 差不多。不过你的 token 在 url 里面,可以 handler.handshake 函数里面验证,这样就不需要定时器了。

@huahuacn
Copy link
Author

请问你会考虑写一个master/slave方式的gate服务吗?我试着搞了一天,逻辑分离得依然不清楚。有点难。

@hanxi
Copy link
Owner

hanxi commented Nov 20, 2020

请问你会考虑写一个master/slave方式的gate服务吗?我试着搞了一天,逻辑分离得依然不清楚。有点难。

最近没空搞,等有空再考虑吧,你能写出来就更好了。 😄

@huahuacn
Copy link
Author

我试了两天,写了几版好像不太行=。=

hanxi added a commit that referenced this issue Nov 23, 2020
@hanxi
Copy link
Owner

hanxi commented Nov 23, 2020

@mikewu86 随意写了下,你拿去改改看吧,应该能满足你的需求。
https://github.com/hanxi/skynet-demo/tree/multi-gate

@huahuacn
Copy link
Author

超赞~~

@huahuacn
Copy link
Author

感谢~~

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