大型游戏网站的可扩展性建议

发布于 2024-09-25 09:53:23 字数 908 浏览 12 评论 0原文

我正在建立一个网站,玩家可以在其中玩回合制游戏以获得虚拟积分(类似于扑克网站,但有所不同)。我想出的设置:

  • 一个数据服务器,其中包含所有玩家帐户以及相关数据(数据库+服务)。如果有帮助的话,数据库和 API 可以分为两个服务器。
  • 为网站提供服务的一台或多台网络服务器,在需要时连接到数据服务器。
  • 一个大厅服务器,玩家可以在其中找到彼此并设置游戏(可以有多个,但不太用户友好)
  • 运行游戏的多个游戏服务器(所有规则等都在服务器上,客户端只是一个遥控器和查看器) ,带有一个负载均衡器。
  • 游戏客户端

客户端将使用Flash制作,网络服务器将使用PHP。剩下的都是Java。

通讯

  • 玩家登录网站。网络服务器将用户名/密码发送到数据服务器,数据服务器创建会话密钥(如 cookie)
  • 玩家启动客户端。客户端连接到大厅服务器,传递会话密钥。大厅服务器与数据服务器检查此密钥
  • 一旦创建了大厅并且必须开始游戏,大厅服务器就会从负载平衡器获取游戏服务器并在此游戏服务器上设置游戏。
  • 大厅服务器告诉客户端连接到游戏服务器并开始游戏。
  • 当游戏结束时,游戏服务器通知大厅服务器。大厅服务器将检查分数并更新数据服务器中的积分。

协议

  • Java 到 Java:RMI
  • PHP 或 Flash 到 Java:通过套接字的自定义二进制协议。该协议支持在空闲时关闭套接字,同时保持虚拟连接处于活动状态并可恢复。

如果客户有他的意愿,该网站将需要支持数千个并发玩家。有了这些信息,您能发现我的设置中存在任何瓶颈吗?我个人有点担心只存在一个数据服务器,但我不确定如何将其拆分。也欢迎其他可扩展性(或其他)评论。

I'm building a website where players can play a turn based game for virtual credits (like a Poker site, but different). The setup I came up with:

  • One data server which contains all player accounts with associated data (a database + service). Database and API may be split into two servers, if that helps.
  • One or more webservers which serve the website, connecting to the data server when needed.
  • One lobby server where players can find eachother and set up games (multiple is possible, but less user friendly)
  • Multiple game servers where the game is run (all rules and such are on the server, the client is just a remote control and viewer), with one load balancer.
  • A game client

The client will be made with Flash, the webserver will use PHP. The rest is all Java.

Communications

  • Player logs in on the site. Webserver sends username/password to data server, which creates a session key (like a cookie)
  • Player starts the client. Client connects to lobby server, passing the session key. Lobby server checks this key with the data server
  • Once a lobby is created and a game must start, the lobby server fetches a game server from the load balancer and sets up a game on this game server.
  • Lobby server tells the clients to connect to the game server and the game is played.
  • When the game is finished, the game server lets the lobby server know. The lobby server will check the score and update the credits in the data server.

Protocols:

  • Java to Java: RMI
  • PHP or Flash to Java: Custom binary protocol via socket. This protocol supports closing the socket when idle while keeping the virtual connection alive and resumable.

If the client has his wishes, the site will need to support thousands of concurrent players. With this information, can you see any bottlenecks in my setup? I'm personally a little bit worried about the existence of only one data server, but I'm not sure how to split that up. Other scalability (or other) remarks are also welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月静好 2024-10-02 09:53:23

您的架构具有许多单一服务,这些服务对于系统的任何部分为任何用户工作都至关重要。我认为这些SPOF

  • 您可能需要考虑对数据服务器进行分片(或水平分区)。
  • 考虑使用多个大厅服务器。如果您愿意,Flash 客户端仍然可以将它们伪装成单个大厅。就我个人而言,我不喜欢和那些我无法用我不懂的语言交谈的人玩游戏。另外,我不喜欢加入大厅服务器,发现有 n 千个游戏并且不认识任何人。让多个大厅成为一个特色(当你认真思考时,你真的可以)。 10000人的大厅没有什么实际用处。如果您仍然想继续下去,您仍然可以尝试分区,基于玩家过滤特定参数(对手级别、游戏类型等)的假设,尝试按照一个甚至多个标准分割大厅。
  • 我认为负载平衡器实际上不需要足够的电力来成为物理服务器。为什么不在所有大厅服务器上复制它?它所需要知道的只是可用性/服务器。假设,你有 10000 个游戏服务器(我认为在这种情况下是一大堆)和 1 秒的刷新率(这在这里远远不够),你同步的只是每秒 10000 个整数(让我们假设你可以将可用性表示为数字(我想你可以))。如果您想出比将每个游戏服务器与每个大厅服务器连接更好的方法,那么这甚至不需要在一台计算机上有太多连接。

在这种类型的应用程序中,我认为水平分区是一个好主意,因为它可以轻松完成并增加系统的可靠性。假设您的 SPOF 已分区,而不是冗余。这更容易而且可能更便宜。如果 SPOF 的一部分发生故障(假设您的 20 个独立的物理分布式数据服务器中的 1 个),那就很糟糕,因为您的 5% 的玩家被锁定。但可能很快就会起来。如果您的 SPOF 是多余的,那么出现任何问题的可能性就会降低。但如果真的发生了,每个人都被锁在门外。这是一个问题,因为每个人都会同时尝试恢复在线状态。一旦您的 SPOF 回来,它将受到比通常需要处理的数量级高的请求量的影响。您仍然可以同时采用水平分区和冗余,正如平衡服务所建议的那样。

Your architecture has a lot of single services that are crucial for ANY part of the system to work for ANY user. I considers these SPOFs.

  • You might want to consider sharding (or horizontal partitioning) for your data server.
  • Consider multiple lobby servers. The flash client can still disguise them as a single lobby, if you want to. Personally, I don't like playing games with people I cannot talk to in any language I don't understand. Also, I don't like joining a lobby server finding n-thousand games and not knowing anyone. Make multiple lobbies a feature (when you put thought into it, you really can). There's no real use for a lobby with 10000 people. If you still wanna go through with it, you could still try partitioning, based on the assumption that a player filters for specific parameters (opponent level, game type, etc.), trying to split lobbies along one or even multiple criteria.
  • The load balancer doesn't actually require enough power to be a physical server I suppose. Why not replicate it on all lobby servers? All it has to know is availability / server. Assuming, you have 10000 game servers (which I think is a whole fucking lot in this case) and a refresh rate of 1 second (which is far more than enough here), all you sync is 10000 integers per second (let's assume you can represent availability as a number (which I suppose you can)). If you figure out something better than connecting every game server with every lobby server, this doesn't even require too many connections on a single machine.

In this type of application, I think horizontal partitioning is a good idea, because for one it can be done easily and adds reliability to the system. Assume your SPOFs are partitioned, rather than redundant. This is easier and possibly cheaper. If a part of an SPOF goes down (let's say 1 of your 20 independent and physically distributed data servers), this bad, because 5% of your players are locked out. But probably it will get up some time soon. If your SPOF is redundant, chances are lower that anything fails. But if it does, EVERYBODY is locked out. This is an issue, because you'll have everybody trying to get back online all at the same time. Once your SPOF is back, it'll be hit by an amount of request orders of magnitude higher than it has to handle usually. And you can still employ horizontal partitioning and redundancy at the same time, as proposed for the balancing service.

呆橘 2024-10-02 09:53:23

在开发过几款 Facebook 游戏后,我想说的是:

要考虑对数千名玩家的可扩展性,但你必须先获得数以万计的玩家,然后才能为这些玩家进行扩展的努力得到回报。

也就是说,提前计划,但在规划一个可容纳数千个并发玩家的系统之前,先要担心只有 1 个玩家。

我怀疑您描述的设置对于您的初始用户群来说效果很好。在构建时,请避免执行以下操作: 要求登录服务器与大厅服务器通信。让每个服务器独立存在,最让你丧命的是服务之间的相互依赖。

但最重要的是,以最方便的方式完成它。如果你有足够多的用户来对你的系统征税,那将是一件非常好的事情。您可以聘请 DBA 来帮助您弄清楚当您拥有这么多用户时如何进行扩展。

Having worked on a couple of facebook games, I would say this:

Be thinking about scalability for thousands of players, but you have to get tens of thousands of players before the effort of scaling for those players will pay off.

That is to say, plan ahead, but worry about getting 1 player before you plan a system for thousands of concurrent players.

I suspect that the setup you describe will perform pretty well for your initial user-base. While you are building, avoid doing things like: Requiring the login server to talk to the lobby server. Make each server stand on it's own, the big thing that will kill you is inter-dependency between services.

But the most important thing, is to get it done in the most expedient way you can. If you get enough users to tax your system, that will be a really good thing. You can hire a DBA to help you figure out how to scale out when you have that many users.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文