Amazon GameLift
Developer Guide (Version )

Spot Fleet Integration Guide

When setting up fleets of hosting resources, you have the option of using both spot instances and on-demand instances. Learn more about how Amazon GameLift uses spot instances in On-Demand versus Spot Instances. If you choose to use spot fleets, you'll need to make a few adjustments to your game integration.

Are you using FlexMatch for matchmaking? You can use spot fleets with your existing queues for matchmaking placements.

To set up game and hosting resources for spot fleets:

  1. Design a queue with a "spot-optimized" configuration. Managing fleet usage with a queue is always a best practice, but it's required when using spot instances. For this step, you'll need to identify which regions to cover in the queue, select the right instance types (hardware) for your game, and decide how you want FleetIQ to prioritize game session placement. As a best practice, each region supported your queue show have more than one spot fleet and one on-demand fleet. The spot fleets should use different instance types, ideally in the same family (C4.large, C4.xlarge, etc.). This design increases the resiliency of your game servers. See Design a Queue for Spot Instances for help designing a spot-optimized queue.

    Once you've created the fleets for your queue, you can create the queue, add fleet destinations, and set fleet prioritization. See Create a Queue for help creating and configuring the new queue.

  2. Create the fleets for your spot-optimized queue. Before creating the queue, you need to create the fleets for it. Spot fleets and on-demand fleets can have identical configurations, with the only difference being the fleet type designation. See Create a Fleet for help creating and configuring new fleets.


    We recommend that you include the fleet type (spot or on-demand) in the fleet name. This will make it easy to identify your spot fleets at a glance in a list of fleet names, such as when adding fleets to a queue.

  3. Enable your game client or client service to place new game sessions using the spot-optimized queue. If you're not already doing so, update your game client code to use game session placement with a queue rather than creating game sessions on a single specific fleet. By using the queue to place game sessions, you're enabling FleetIQ to select the best available fleet based on cost, interruption rate, and player latency. You're also providing fallback hosting resources in case a preferred fleet is temporarily not available for use. For help implementing game session placements in your game client, see Create Game Sessions.

  4. Enable your game server to handle a spot interruption. Spot instances can be interrupted with two minutes' notification when AWS needs the capacity back. You'll want your game server to handle an interruption gracefully, if it happens, and minimize the player impact. When AWS is about to reclaim a spot instance, it sends termination notification up to two minutes before, which Amazon GameLift passes on to all affected server processes. This is done by invoking the Server SDK callback function onProcessTerminate(). Implementing this callback function is always a best practice, but it is particularly important when using spot instances. The implementation of this callback can take action to either gracefully end the game sessions or find a way to move the game sessions and players to a new placement. See Shut Down a Server Process for help implementing onProcessTerminate().


    AWS makes every effort to provide the notification as soon as an instance is chosen for termination, but there is the possibility that the spot instance will be terminated before the warning arrives. Your game server should be prepared to handle unexpected interruptions.

  5. Evaluate the performance of your spot fleets and queues. Once the new queue is actively placing new game sessions, use Amazon GameLift metrics to evaluate performance. Key metrics include:

    • Interruption rate – Track the number and frequency of spot-related interruptions for instances and game sessions in a spot fleet. These fleet metrics (InstanceInterruptions and GameSessionInterruptions) can be viewed in the Amazon GameLift console or by using Amazon CloudWatch (see Amazon GameLift Metrics for Fleets). If you aggregate fleet metrics in a metrics group, you can also view interruptions by instance type and operating system in CloudWatch. Game sessions that were terminated for spot-related reasons have a status of "TERMINATED" and a status reason of "INTERRUPTED".

    • Queue effectiveness – Track metrics for your queues, including placement success rates, average wait time, and queue depth to verify that the use of spot fleets has no impact on queue performance. Queue metrics can be viewed in the Amazon GameLift console or by using Amazon CloudWatch.

    • Fleet utilization – Monitor usage rates for your fleets, including data on instances, game sessions and player sessions. Usage for your on-demand fleets can be an indicator that FleetIQ is choosing to avoid risky placements into spot fleets and falling back to the on-demand fleets. Fleet utilization metrics can be viewed in the Amazon GameLift console or by using Amazon CloudWatch.