Skip to main content

Guidance for Multiplayer Session-Based Game Hosting on AWS

Overview

This Guidance helps game developers get started with multiplayer game development by using Amazon GameLift for low-latency global game server hosting and matchmaking. It supports Unity, Unreal, and Godot game engines on the client side and provides sample integrations with Amazon GameLift for multiple game server implementation options, including C++, Go, Unity, and Unreal. This Guidance also implements best practices for integrating your game backend with Amazon GameLift in addition to observability with Amazon CloudWatch through near real-time game server logs, process-level game server metrics, and distributed tracing for backend APIs.

How it works

These technical details feature an architecture diagram to illustrate how to effectively use this solution. The architecture diagram shows the key components and their interactions, providing an overview of the architecture's structure and functionality step-by-step.

Well-Architected Pillars

The architecture diagram above is an example of a Solution created with Well-Architected best practices in mind. To be fully Well-Architected, you should follow as many Well-Architected best practices as possible.

Amazon GameLift manages game server fleets globally with a highly available configuration in each location, allowing you to configure how you want the game server fleet to scale and operate. Serverless services such as API Gateway, Lambda, and DynamoDB reduce the operational effort by managing underlying infrastructure on your behalf, so you can focus on code and configuration. By using CloudWatch to monitor all the components of the Guidance through metrics and logs, you can investigate bottlenecks or errors in near real time.

Read the Operational Excellence whitepaper 

API Gateway supports authentication of requests to validate user identities with the JSON Web Token provided by the game client and the public keys provided by the Custom Identity component. Authentication helps ensure players are who they claim to be when accessing their data on the backend Lambda functions.

Read the Security whitepaper 

Amazon GameLift provides high availability in all Regions through hosting the game server instances in multiple Availability Zones (AZs). It will also automatically replace any failed game server processes or instances.

The DynamoDB table for matchmaking tickets allows automatic horizontal scaling as the player load increases. DynamoDB also hosts in multiple AZs within the Region. The matchmaking tickets are considered ephemeral (and are also automatically deleted after 3 hours), so you don’t need to do backups on the table.

For notifications on any availability issues, we recommend implementing CloudWatch alarms on appropriate metrics from Amazon GameLift for game servers in addition to any errors on the API Gateway and Lambda layers.

Read the Reliability whitepaper 

Amazon GameLift allows direct client-to-server communication to optimize near real-time performance. This architecture diagram allows developers to host game servers using Amazon GameLift across multiple Regions, reducing the latency between the game client and the server. DynamoDB stores the matchmaking results and allows you to retrieve them with single-digit millisecond response times at scale.

Read the Performance Efficiency whitepaper 

The DynamoDB Time to Live (TTL) feature deletes items from your table after 3 hours without consuming any write throughput. This provides enough time for you to have the items available when you need them, but minimizes overall cost for unnecessary storage.

Amazon GameLift allows you to use a combination of Amazon Elastic Compute Cloud (Amazon EC2) On-Demand and Spot instances. Configuring an On-Demand fleet and Spot fleet behind the same Amazon GameLift queue can help reduce cost through a built-in Spot optimization algorithm of Amazon GameLift, which uses Spot as the preferred choice when available.

Read the Cost Optimization whitepaper 

Amazon GameLift requires at least a single instance per Region to allow appropriate response times and to initiate scaling of the service, but the locations can be scaled to 1 at times of low traffic and to 0 for development and test environments.

Additionally, the serverless services used by the backend, including DynamoDB, Lambda, and API Gateway scale based on demand to match the required capacity, reducing the compute footprint of this Guidance.

Read the Sustainability whitepaper 

Deploy with confidence

Ready to deploy? Review the sample code on GitHub for detailed deployment instructions to deploy as-is or customize to fit your needs. 

Go to sample code

Disclaimer

The sample code; software libraries; command line tools; proofs of concept; templates; or other related technology (including any of the foregoing that are provided by our personnel) is provided to you as AWS Content under the AWS Customer Agreement, or the relevant written agreement between you and AWS (whichever applies). You should not use this AWS Content in your production accounts, or on production or other critical data. You are responsible for testing, securing, and optimizing the AWS Content, such as sample code, as appropriate for production grade use based on your specific quality control practices and standards. Deploying AWS Content may incur AWS charges for creating or using AWS chargeable resources, such as running Amazon EC2 instances or using Amazon S3 storage.