Manage how GameLift launches game servers - Amazon GameLift
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Manage how GameLift launches game servers

You can set up an Amazon Elastic Compute Cloud fleet's runtime configuration to run multiple game server processes per instance. By doing this, you're using your hosting resources more efficiently.

How a fleet manages multiple processes

Amazon GameLift uses a fleet's runtime configuration to determine the type and number of processes to run on each instance. A runtime configuration contains at least one server process configuration that represents one game server executable. You can define additional server process configurations to run other types of processes related to your game. Each server process configuration contains the following information:

  • The file name and path of an executable in your game build.

  • (Optional) Parameters to pass to the process on launch.

  • The number of processes to run concurrently.

When an instance in the fleet activates, it launches the set of server processes defined in the runtime configuration. With multiple processes, GameLift staggers the launch of each process, which has a limited life span. As they end, GameLift launches new processes to maintain the number and type of server processes defined in the runtime configuration.

You can change the runtime configuration at any time by adding, changing, or removing server process configurations. Each instance regularly checks for updates to the fleet's runtime configuration, ensuring that the changes are implemented. Here's how GameLift adopts runtime configuration changes.

  1. The instance sends a request to the GameLift service for the latest version of the runtime configuration.

  2. The instance compares its active processes to the latest runtime configuration and updates as follows:

    • If the updated runtime configuration removes a server process type: Active server processes of this type continue to run until they end, and aren't replaced.

    • If the updated runtime configuration decreases the number of concurrent processes for a server process type: Excess server processes of this type continue to run until they end, and aren't replaced.

    • If the updated runtime configuration adds a new server process type or increases the concurrent processes for an existing type: The instance starts new server processes, up to the GameLift maximum. In this case, the instance launches new server processes as existing processes end.

Optimize a fleet for multiple processes

To use multiple processes on a fleet, do the following:

  • Create a build that contains the game server executables that you want to deploy to a fleet and upload it to GameLift. All game servers in a build must run on the same platform, and use the GameLift Server SDK.

  • Create a runtime configuration with one or more server process configurations and multiple concurrent processes.

  • Integrate game clients with the Amazon SDK version 2016-08-04 or later.

To optimize fleet performance, consider the following recommendations:

  • Handle server process shutdown scenarios so GameLift can recycle processes efficiently.

    • Add a shutdown procedure to your game server code that calls server API ProcessEnding().

    • Implement the callback function OnProcessTerminate() in your game server code to handle termination requests from GameLift.

  • Make sure that GameLift shuts down and relaunches unhealthy server processes. Report the health status back to GameLift by implementing the OnHealthCheck() callback function in your game server code. GameLift automatically shuts down server processes that are reported unhealthy for three consecutive reports. If you don't implement OnHealthCheck(), GameLift assumes that a server process is healthy, unless the process fails to respond to a communication.

Choose the number of processes per instance

When deciding on the number of concurrent processes to run on an instance, there are three limits to keep in mind:

  • GameLift limits each instance to a maximum number of concurrent processes. The sum of all concurrent processes for a fleet's server process configurations can't exceed this quota.

  • The Amazon EC2 instance type might limit the number of processes that can run concurrently to maintain acceptable performance levels. Test different configurations for your game to find the right number of processes for your preferred instance type.

  • When changing a fleet's runtime configuration, keep in mind that GameLift doesn't run more concurrent processes than the total number configured. This means that the transition from the previous runtime configuration to the new configuration might happen gradually.