Use Spot Instances with Amazon GameLift - Amazon GameLift

Use Spot Instances with Amazon GameLift

When setting up yourAmazon GameLift managed EC2 fleet, you can use Spot Instances, On-Demand Instances, or a combination. Learn more about how Amazon GameLift uses Spot Instances in On-Demand Instances versus Spot Instances. To use spot fleets, your game integration requires the adjustments listed on this page.

Are you using FlexMatch for matchmaking? You can add Spot fleets to your existing game session queues for matchmaking placements.

  1. Design your game session queue for Spot instances.

    Managing game session placement with a queue is best practice, and it's required when using Spot Instances. To design your queue consider the following:

    • Locations – To achieve the best player experience, choose locations geographically close to your players.

    • Instance types – Consider your game servers hardware requirements and availability of instances in the locations you chose.

    To try a queue that optimizes Spot availability and resiliency, see Tutorial: Set up a game session queue for Spot Instances.

  2. Create the fleets for your Spot-optimized queue.

    Based on your queue design, create fleets to deploy your game servers to your desired locations and instance types. See Create a Amazon GameLift managed fleet for help creating and configuring new fleets.

  3. Create your game session queue.

    Add the fleet destinations, configure the game session placement process, and define placement priorities. See Create a game session queue for help creating and configuring the new queue.

  4. Update your game client service to use the queue.

    When your game client uses a queue to request resources, the queue avoids resources with a high chance of interruption and selects the location that matches your defined priorities. For help implementing game session placements in your game client, see Create game sessions.

  5. Update your game server to handle a Spot interruption.

    AWS can interrupt Spot Instances with a 2 minute notification, when it needs the capacity back. Set up your game server to handle interruption to minimize player impact.

    Before AWS reclaims a Spot Instance, it sends a termination notification. Amazon GameLift passes the notification to all affected server processes by invoking the Amazon GameLift Server SDK callback function onProcessTerminate(). Implement this callback to end the game session or move the game session and players to a new instance. See Respond to a server process shutdown notification for help implementing onProcessTerminate().


    AWS makes every effort to provide the notification before it reclaims and instance, but it's possible that AWS reclaims the Spot Instance before the warning arrives. Prepare your game server to handle unexpected interruptions.

  6. Review the performance of your Spot fleets and queues.

    View Amazon GameLift metrics in the Amazon GameLift console or with Amazon CloudWatch to review performance. For more information about Amazon GameLift metrics, see Monitor Amazon GameLift with Amazon CloudWatch. Key metrics include:

    • Interruption rate – Use the InstanceInterruptions and GameSessionInterruptions metrics to track the number and frequency of Spot-related interruptions for instances and game sessions. Game sessions that reclaimed by AWS have a status of TERMINATED and a status reason of INTERRUPTED.

    • Queue effectiveness – Track placement success rates, average wait time, and queue depth to confirm that Spot fleets don't impact your queue performance.

    • Fleet usage – Monitor data on instances, game sessions and player sessions. Usage for your On-Demand fleets can be an indicator that queues are avoiding placements into your Spot fleets to avoid disruption.