简体   繁体   English

多人游戏的可扩展登录/大厅服务器

[英]Scalable login/lobby servers for a multiplayer game

I am developing a multiplayer game (client-server model) and I am stuck when it comes to scaling its servers.我正在开发一款多人游戏(客户端-服务器模型),但在扩展其服务器时遇到了困难。

I understand that most games never even reach 10 000+ players, and I don't think mine will either.据我所知,大多数游戏甚至从未达到 10,000+ 玩家,我认为我的游戏也不会。 Though if I would be very lucky to get that I want to develop the servers so they cannot become a huge obsticle later.虽然如果我很幸运能得到它,我想开发服务器,这样它们以后就不会变成一个巨大的障碍物。

I have searched a lot for a solution to my problem on the inte.net, checking GDC talks about it and checking other posts on this website, but none of them seems to solve my specific problem.我在 inte.net 上搜索了很多关于我的问题的解决方案,检查 GDC 谈论它并检查该网站上的其他帖子,但它们似乎都没有解决我的具体问题。

My current setup is below and all servers are written in C++ using ENet as my.network library.我当前的设置如下,所有服务器都使用 ENet 作为 my.network 库以 C++ 编写。

Game server游戏服务器

This server handles the actual gameplay of the game and requires quite a lot of CPU and packages being sent between the server and its connected clients.该服务器处理游戏的实际游戏玩法,需要大量 CPU 和在服务器与其连接的客户端之间发送的数据包。 But this dedicated server is hosted by the players themselves, so I don't have to think about scaling it at all.但是这个专用服务器是由玩家自己托管的,所以我根本不用考虑扩展它。

Lobby server大堂服务员

This server handles the server list, containing all servers currently up.该服务器处理服务器列表,其中包含所有当前运行的服务器。

  • All game servers are sending a UDP package to this server every 5 seconds to say they are still alive.所有游戏服务器每 5 秒发送一次 UDP package 到这个服务器,表示他们还活着。 This is so the lobby server can keep an updated list of all servers currently online.这样大堂服务器可以保留当前在线的所有服务器的更新列表。

  • All clients are sending a UDP package to this server when they want to fetch all servers (which is only in the server list screen), and the lobby server sends back a list of all servers.当所有客户端想要获取所有服务器(仅在服务器列表屏幕中)时,所有客户端都向该服务器发送 UDP package,并且大厅服务器发回所有服务器的列表。 This does not happen that often and the lobby server is limited to send 4 servers per second to a client (and not a huge package containing all servers).这种情况不会经常发生,大厅服务器被限制为每秒向客户端发送 4 个服务器(而不是包含所有服务器的巨大 package)。

Login server登录服务器

This server handles creating accounts, lost password, logins, friends and their current game status, private messages to other logged in players and player profiles that specifies what in-game items they have.该服务器处理创建帐户、丢失密码、登录、朋友和他们当前的游戏状态、发送给其他登录玩家的私人消息以及指定他们拥有的游戏内物品的玩家资料。

  • All clients are sending a UDP package to this server every 5 seconds to say they are still alive, while also sending what game they are currently in. The server then sends back their friend lists online/offline/in-game statuses.所有客户端每 5 秒向该服务器发送一次 UDP package 以表明他们还活着,同时还发送他们当前所在的游戏。服务器然后发回他们的好友列表在线/离线/游戏中状态。 This is so their friends can keep an updated list of which friend is online/offline/in-game.这样他们的朋友就可以更新在线/离线/在游戏中的朋友列表。

  • It sends messages only with player actions otherwise, like creating an account, logging in, changing/resetting password, adding/removing/ignoring a friend, private messages to friends, etc.它只发送玩家操作的消息,否则,如创建帐户、登录、更改/重置密码、添加/删除/忽略朋友、给朋友的私人消息等。

My questions我的问题

What I am worried about is that my lobby and login server might not be scalable and that they would have too much traffic on them.我担心的是我的大厅和登录服务器可能无法扩展,而且它们的流量会太大。

1. Could they in theory be hosted on just a single computer? 1.理论上它们可以托管在一台计算机上吗? Or would it be too much traffic for 10 000+ players?或者对于 10 000 多名玩家来说流量会太多吗?

2. If they can be hosted on a single computer, will the servers still not have issues for people that live far away? 2.如果他们可以托管在一台计算机上,服务器对于住在很远的人来说仍然没有问题吗?
Would it be better to have the lobby and login servers per region of the world in that case?在这种情况下,世界上每个地区都有大厅和登录服务器会更好吗? The bad thing about that is that the players would not be able to see servers in the US if they live in Europe, and that their account and items would not exist on the other servers.这样做的坏处是,如果玩家住在欧洲,他们将无法在美国看到服务器,并且他们的帐户和物品将不会存在于其他服务器上。

3. Might be far-fetched, but if I would rewrite both servers to instead be on a website with a database and make the client/game server do web requests instead (such as HTTPS or calling a php with specific headers), would it help in solving my problems somehow? 3.可能有点牵强,但如果我重写两个服务器,而不是在一个有数据库的网站上,并让客户端/游戏服务器改为执行 web 请求(例如 HTTPS 或调用具有特定标头的 php),它会不会以某种方式帮助解决我的问题?

All your problems and questions are solved by serverless cloud based solution AWS Lambda eg or similar.您的所有问题和问题都由基于无服务器云的解决方案AWS Lambda例如或类似解决方案解决。 In this case the scalability is not your problem.在这种情况下,可伸缩性不是您的问题。 Just develop the logic.只是发展逻辑。 This will save you much time.这将为您节省很多时间。

If you would like to make servers as single app hosted by your own server.如果您想将服务器作为由您自己的服务器托管的单个应用程序。 Consider using something like eg Go instead of C++. It's designed exactly for these purposes.考虑使用像 Go 这样的东西而不是 C++。它正是为这些目的而设计的。 I mean highly loaded web.network services.我的意思是高负载的 web.network 服务。

Well, this is c++ and i code in java, but maybe the logic is useful for you any way so i will tell you how i end up implementing something similar but in a casino.嗯,这是 c++,我在 java 中编码,但也许逻辑对你有用,所以我会告诉你我如何最终实现类似的东西,但在赌场。

In my case I have 2 diferrent sockets in the same server program, one of the sockets is TCP and it handles all logins, registers and payments, while the second socket is UDP and it handle the actual game multiple payers are playing, then you could group internally all those UDP connection in groups (probably arrays of sockets) to generate those lobbies.在我的例子中,我在同一个服务器程序中有 2 个不同的 sockets,其中一个 sockets 是 TCP,它处理所有登录、注册和支付,而第二个套接字是 UDP,它处理多个付款人正在玩的实际游戏,那么你可以在内部将所有这些 UDP 连接分组(可能是 arrays 套接字)以生成这些大厅。 Doing that all your server is just one class that could run in a single pc using 2 ports (one for each socket) However this do not solve the problem of the ping for people who live far away.这样做你所有的服务器只是一个 class,它可以在一台 pc 上运行,使用 2 个端口(每个插座一个)但是这并不能解决住在很远的人的 ping 问题。 If ping is a problem (not my case in a casino) you could probably host your server region base but removing the login, registration and paymets of your server and replace it for a connection to a central server (this central server should be TCP and you could also implement a https socket to also allow your webpage to connect to this server and create accounts or pay you directly from the browser)如果 ping 是一个问题(不是我在赌场的情况),你可能会托管你的服务器区域基地,但删除你的服务器的登录,注册和支付并替换它以连接到中央服务器(这个中央服务器应该是 TCP 和您还可以实现一个 https 套接字,以允许您的网页连接到该服务器并创建帐户或直接从浏览器向您付款)

sorry to mess your life even more, but i hope it helps很抱歉让你的生活更加混乱,但我希望它能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM