Development Blog

Pre-Production: Anywhere Fleets vs fleets (+ game and player sessions)

Tutorial Pre-Production
Anywhere Fleets vs. AWS Fleets: Hosting a Game with AWS
When hosting a game with AWS, there are two primary approaches: Anywhere Fleets and AWS Fleets.

Anywhere Fleets

Anywhere Fleets allow the user’s device to act as a server while connecting to AWS GameLift to enable other players to join the session. This solution is convenient for testing but comes with several limitations:
  1. Scalability Issues – A single PC cannot efficiently handle multiple simultaneous game sessions.
  2. Geographical Constraints – The hosting PC is located in one region, leading to high latency for players in different parts of the world.
  3. Hardware Limitations – Without dedicated infrastructure, performance may be inconsistent.

AWS Fleets

AWS provides a solution by offering dedicated servers in the form of EC2 instances (virtual machines running selected operating systems). This approach resolves the issues faced with Anywhere Fleets by providing scalable, global infrastructure.
However, when creating an EC2 instance, the operating system is initially fresh and lacks the necessary libraries required by Unreal Engine to run the server. To address this, Unreal packages an executable within the server build that installs all the required prerequisites. This executable can be found in:
Engine\Extras\Redist\en-us
To ensure this setup runs automatically on the virtual machine, we can create a batch script that executes the installation at startup. The script would look like this:
Engine\Extras\Redist\en-us\UEPrereqSetup_x64 /install /quiet /norestart /log c:\game\vcredist_2013_x64.log

Managing Game Sessions and Player Sessions in AWS GameLift

Once the server is running, AWS GameLift requires information about game sessions and the players joining each session. While this process can later be automated using C++ code and UI buttons, we can first demonstrate it using AWS CLI commands.

Creating a Game Session

To create a game session, use the following command:
aws gamelift create-game-session --fleet-id <fleet id> --name <Game Session name> --maximum-player-session-count <max players> --location < custom location>
Upon execution, the response will contain details about the game session, including its status, which should initially appear as ACTIVATING. After a few seconds, checking the AWS console should show the status as ACTIVE, meaning players can join.
If the response gets lost in the command line, you can retrieve active game session details using:
aws gamelift describe-game-sessions --fleet-id <fleet id> --status-filter ACTIVE
This command lists all active game sessions.

Creating a Player Session

Once a game session is active, you can create a player session. This request needs approval from the server and has a built-in timer for completion. Since this timer lasts only a few seconds, automation is recommended for production use.
To manually create a player session, use the following command:
aws gamelift create-player-session --game-session-id <game session id> --player-id <player name>