[英]How does one scale dedicated EC2 instances on AWS?
I'm creating on online real-time multiplayer mobile game using Kryonet (a Java TCP/UDP networking library) that I'm planning to host on AWS. 我正在使用计划在AWS上托管的Kryonet(Java TCP / UDP网络库)在在线实时多人手机游戏上进行创建。
The architecture is as follows: clients connect to a central login/account server that allows them to login and view their stats etc. This bit is easy, as it'll basically just be a REST API, and can be scaled in a pretty standard way (like you would any webapp). 架构如下:客户端连接到中央登录/帐户服务器,使他们可以登录并查看其统计信息等。这一点很容易,因为它基本上只是一个REST API,并且可以按相当标准进行扩展方式(就像您使用任何webapp一样)。
However, the more interesting bit is when players actually play a match. 但是,更有趣的一点是玩家实际进行比赛时。 For this, I plan to have a separate pool of "match" servers (EC2s).
为此,我计划有一个单独的“匹配”服务器(EC2)池。 The login/account server will pair two players, then send the client the address of a particular match server.
登录/帐户服务器将配对两个玩家,然后向客户端发送特定比赛服务器的地址。 The players will then join that match server, which will host their match (perhaps lasting 5-10 minutes).
然后,玩家将加入该比赛服务器,该服务器将主持比赛(可能持续5-10分钟)。 The match server needs to be sticky as it will be running a real-time instance of the game, and will be sending/receiving UDP packets in real time.
比赛服务器必须保持粘性,因为它将运行游戏的实时实例,并且将实时发送/接收UDP数据包。 Each match server will probably be able to host a few hundred matches.
每个比赛服务器将可能能够主持数百场比赛。
My question is about how I should go about scaling these match servers. 我的问题是我应该如何扩展这些匹配服务器。 I suppose I will have them auto-register with the central server at start-up, and send some type of keep alive.
我想我将在启动时让它们在中央服务器上自动注册,并发送某种类型的保持活动状态。 I could build this all myself;
我可以自己建造所有这些; however, I'm wondering if AWS has tools/services that can do this all for me.
但是,我想知道AWS是否具有可以为我完成所有任务的工具/服务。
Okay, I've done a little more reading of the AWS documentation. 好的,我已经阅读了一些有关AWS文档的内容。 It seems that I can probably achieve this as follows:
看来我可能可以达到以下目的:
Each time two players are paired up, they are added to a queue. 每次将两个玩家配对时,它们就会添加到队列中。 They are taken off the queue when a spot is free on one of the match-playing servers.
当其中一台比赛服务器上有空位时,它们将从队列中移出。 When the size of this queue exceeds some threshold, then the number of EC2s is scaled.
当此队列的大小超过某个阈值时,将缩放EC2的数量。 This can be done with basically all in AWS config: http://docs.aws.amazon.com/autoscaling/latest/userguide/as-using-sqs-queue.html
基本上,所有这些都可以在AWS配置中完成: http : //docs.aws.amazon.com/autoscaling/latest/userguide/as-using-sqs-queue.html
The tricky bit is then scaling down instances. 然后,棘手的一点是按比例缩小实例。 Unlike a normal REST API, you can't just turn a server off.
与普通的REST API不同,您不能仅关闭服务器。 The server needs to finish all its current games.
服务器需要完成其所有当前游戏。 It seems that AWS has this covered too with lifecycle hooks.
看来,AWS的生命周期挂钩也涵盖了这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.