How-tos

How To Get Started with AWS GameLift – CloudSavvy IT


GameLift Header Image

GameLift is a platform built by AWS specifically created for running video game servers. It is built to save costs by automatically scaling the number of instances based on the fluctuating demand, and it can also handle matchmaking for you.

What Is GameLift?

Every match played online must have a server running to host it, which can get expensive very quickly. To make matters worse, the demand for game servers usually scales drastically throughout the day, making the peak hours’ demand much greater than what is required overnight.

GameLift handles the scaling of your server architecture automatically, much like EC2 Autoscaling. It can handle basic matchmaking and sort your players into lobbies based on latency. GameLift also supports custom matchmaking rules, which can sort players by skill level and get rid of the need to build and run a seperate matchmaking system.

GameLift has an SDK, and plugins for both Unity and Unreal. You can use this to communicate directly with GameLift, and place players in queues or request new sessions from within your game.

GameLift has two types of servers: “Realtime” servers, and “Custom” game servers. Realtime servers are intended for games that don’t need complex custom servers running a headless copy of the game engine. Think mobile games that really only need a database and some basic logic. You program these using Realtime Script, based in C#.

While these are interesting, they also seem to be quite the hassle and really require you to build your whole game around it, but it can be much cheaper if your game can be outfitted to run on the platform. The “Custom” server option enables you to upload your own server binary, which gives you much more flexibility. With this type of server, GameLift acts as a fancy version of EC2 autoscaling, which is what this article covers and what most people will probably be using anyway.

Alternatives To GameLift

If you don’t want to use GameLift, you have a few options. First, you could run your servers simply on EC2, and use standard EC2 autoscaling instead. If you’re not making use of GameLift’s custom scaling rules, using standard EC2 autoscaling isn’t much different than GameLift. However, there’s a major downside here—on regular EC2 auto-scaling, you want to use spot instances to minimize costs, as they’re often multiple times cheaper than renting On-Demand capacity.

GameLift also uses Spot Instances, but on GameLift there are extra precautions to ensure your server won’t be terminated if it’s currently being used to host a game. And, if it does need to be shut down, GameLift can signal your server to perform the shutdown process gracefully. Statistically speaking, Spot Instance interruptions are fairly rare, but they’ll be better handled on GameLift.

Even still, EC2 Auto-Scaling is probably your best alternative to GameLift on the AWS platform. If you know the baseline number of players you’re going to need to support, you can buy reserved instances for much cheaper than On-Demand instances, and then use On-Demand instances for scaling during peak hours.

Another option is to simply have the client host the server. Some game types , particularly turn-based or casual unranked games, can have one of the clients in the match act as a listen server, with everyone else connecting to that client. However, this isn’t a good idea for running ranked games, because if the listen server closes it can cut the connection to everyone else. It also opens up the possibility of heavy cheating, as the client has full control of the server (if they are selected to host the listen server). All things considered though, this kind of networking can be used for matches between friends, or for small indie games without the ability to host dedicated servers for everyone.

Creating and Uploading a Build

The first step of using GameLift is the build. You must package your server into a single build that can be uploaded to AWS and ran on a fleet of servers. The build includes your binaries, dependencies, and install script. It can run on Windows or Linux; typically Linux will be cheaper, as there’s less memory overhead and no licensing costs. However, many games aren’t built for Linux, so you may be stuck with Windows. The install script will be a file in the root directory of your game server build called install.bat or install.sh, depending on the platform. The server itself will install to C:game or /local/game/.

You can only upload builds from the AWS CLI. To do so, use the gamelift upload-build command:

aws gamelift upload-build --name <your build name> --build-version <your build number> --build-root <local build path> --operating-system WINDOWS_2012 --region us-east-1

The process of getting a build up and running depends on your game’s configuration. So, if you just want to test out GameLift’s features without going through this process yet, AWS provides a sample game server you can upload using the GameLift Console.

Give your sample build a name, and click upload. In order to use it, you’ll have to create a “Fleet” that uses this build. Fleets are like autoscaling groups—they’re configured to run your game server and host sessions on separate instances. You can create a new fleet by clicking on the build and selecting “Create Fleet From Build,” or you can create the sample fleet from the walkthrough by clicking “Create Fleet.” Both the fleet and build will appear in your console now, though the fleet will likely take about half an hour to create and validate.

How to deploy a game with a custom game server

If you click on the fleet, you can view info about it, such as the current number of sessions and active players and all of the fleet’s lifecycle events.

fleet info

You can also edit the fleet’s settings. You’ll find options to use Spot Instances, change the instance type, and specify the executable that gets launched (and the parameters with which it launches).

fleet settings

From this settings panel, you can also configure your fleet to run multiple game sessions on a single server. If you know how many sessions a given server can support, you can set it here.

In the EC2 port settings, you can configure the number and frequency of your game session activations to allow on each instance.

Once the sample fleet has finished validating, you can then download the sample game client (built with AWS’s Lumberyard game engine, a fork of CryEngine) and connect to it using the token given to you in the tutorial.

As far as actually using your fleet goes, you’ll want to create a “Queue,” which will sort players into matches based on latency. You can specify rules to try to find low latency matches before trying higher latency matches, and select the fleet to which you wish to direct users.

gamelift queue

In order to provide good matchmaking for everyone, you’ll want to have servers around the globe. AWS prices in other regions can get expensive, but if you stick to a few cheap ones, you can cut down on your costs.



READ SOURCE

This website uses cookies. By continuing to use this site, you accept our use of cookies.