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

不同进程放在多个 Docker 容器内 #584

Open
DragonAura opened this issue May 20, 2023 · 2 comments
Open

不同进程放在多个 Docker 容器内 #584

DragonAura opened this issue May 20, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@DragonAura
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
现在的所有进程(Server, Client)都放在同一个 Docker 容器内运行,不利于内存限制、或者分开查看内存、CPU占用。

Describe the solution you'd like
可以通过在不同 Docker 容器内运行各个进程来解决。详情见下面的解决方案:
https://www.runoob.com/docker/docker-container-connection.html
即每一场比赛都创建一个 Network,各个 Client 连接到 Server。

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@TCL606
Copy link
Member

TCL606 commented May 21, 2023

每一场比赛的 Network 怎么互不干扰,也是需要解决的

@TCL606 TCL606 added the enhancement New feature or request label May 21, 2023
@Timothy-Liuxf
Copy link
Member

Timothy-Liuxf commented May 21, 2023

每一场比赛的 Network 怎么互不干扰,也是需要解决的

只需要给每个比赛的 Network 起不同的名字即可。由于每场比赛有个唯一的 ID,所以可以用这个 ID 来起 Network 的名字,比如 thuai-game-network-<id> 等等。游戏开始的时候先创建 Network,然后基于这个 Network 创建各个容器(Server 一个,每个选手的代码各一个,如果是每队四人一共两队就有 9 个;今年非对称竞技是 6 个),然后游戏结束之后除了删容器,再多删一个 Network 就行。Player 容器在连 Server 时不再使用 127.0.0.1 或者 localhost,而是直接用 Server 容器的名字(在同一个 Network 下的各个 Docker 容器可以直接通过容器名连接到该容器的网络,这时容器名相当于域名,使用起来就如同域名通过 DNS 解析到 IP 地址一样)。

(当然如果以后有钱能租 K8S 的话就更简单了;如果队式全面改用 Serverless 架构的话就更更简单了 x)

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

No branches or pull requests

4 participants