Design a queue for Spot Instances - Amazon GameLift

Design a queue for Spot Instances

Create a game session queue to add Spot fleets to your game hosting solution. For more information on Spot Instances and how they can offer significant cost savings for hosting, see On-Demand Instances versus Spot Instances. to take advantage of lower hosting costs with Spot Instances, you must create a game session queue and the lower hoWhen setting up an Amazon GameLift managed fleet to use Spot Instances, On-Demand Instances, or a combination. Learn more about how Amazon GameLift uses Spot Instances in . 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. Determine the destinations for your game session queue.

    Managing game session placement with a queue is best practice, and it's required when using Spot Instances. Because Spot Instances might not always be available when you need them, you need to design a resilient queue that includes both Spot fleets and On-Demand fleets to offer backup capacity. You can keep your On-Demand fleets scaled down until they're needed. To design your queue, consider the following:

    • Locations – Choose locations geographically close to your players. Your Spot fleets and On-Demand fleets should

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

    To try a queue that optimizes Spot availability and resiliency, see Tutorial: Create an Amazon GameLift queue with Spot Instances. For Spot design best practices, see Best practices for Amazon GameLift game session queues.

  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 an Amazon GameLift managed EC2 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().

    Note

    AWS makes every effort to provide the notification before it reclaims an 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 are 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.

Best practices for queues with Spot fleets

If your queue includes Spot fleets, set up a resilient queue. This takes advantage of cost savings with Spot fleets while minimizing the effect of game session interruptions. For help with correctly building fleets and game session queues for use with Spot fleets, see Tutorial: Create an Amazon GameLift queue with Spot Instances. For more information about Spot instances, see Design a queue for Spot Instances.

In addition to the general best practices in the previous section, consider these Spot-specific best practices:

  • Create at least one On-Demand fleet in each location. On-Demand fleets provide backup game servers for your players. You can keep your backup fleets scaled down until they're needed, and use auto scaling to increase On-Demand capacity when Spot fleets are unavailable.

  • Select different instance types across multiple Spot fleets in a location. If one Spot Instance type becomes temporarily unavailable, the interruption affects only one Spot fleet in the location. Best practice is to choose widely available instance types, and use instance types in the same family (for example, m5.large, m5.xlarge, m5.2xlarge). Use the Amazon GameLift console to view historical pricing data for instance types.