StartGameSessionPlacement
Makes a request to start a new game session using a game session queue. When processing a placement request in a queue, Amazon GameLift finds the best possible available resource to host the game session and prompts the resource to start the game session.
Request options
Call this API with the following minimum parameters: GameSessionQueueName, MaximumPlayerSessionCount, and PlacementID. You can also include game session data (data formatted as strings) or game properties (data formatted as key-value pairs) to pass to the new game session.
-
You can optionally change how Amazon GameLift chooses a hosting resource for the new game session. When you configure a game session queue, you can choose to use the default prioritization process, or you can specify a custom process (see PriorityConfiguration.
-
Prioritize based on resource cost, destinations and location, using the queue's configured priority settings. Call this API with the minimum parameters.
-
Prioritize based on latency. You can include a set of values for PlayerLatencies. Provide latency data with or without player session data. This option instructs Amazon GameLift to reorder the queue's locations priority list based on the latency data. If latency data is provided for multiple players, Amazon GameLift calculates each location's average latency for all players and reorders to find the lowest latency across all players. Don't include latency data if you're providing a custom list of locations.
-
Prioritize based on a custom list of locations. If you're using a queue that's configured to prioritize location first (see PriorityConfiguration for game session queues), you can optionally use the PriorityConfigurationOverride parameter to substitute a different location priority list for this placement request. Amazon GameLift searches each location on the priority override list to find an available hosting resource for the new game session. Specify a fallback strategy to use in the event that Amazon GameLift fails to place the game session in any of the locations on the override list.
-
-
You can request new player sessions for a group of players. Include the DesiredPlayerSessions parameter and include at minimum a unique player ID for each. You can also include player-specific data to pass to the new game session.
Result
If successful, this request generates a new game session placement request and adds it
to the game session queue for Amazon GameLift to process in turn. You can track the status of
individual placement requests by calling DescribeGameSessionPlacement. A new game session is running if the status
is FULFILLED
and the request returns the game session connection
information (IP address and port). If you include player session data, Amazon GameLift creates a
player session for each player ID in the request.
The request results in a InvalidRequestException
in the following
situations:
-
If the request includes both PlayerLatencies and PriorityConfigurationOverride parameters.
-
If the request includes the PriorityConfigurationOverride parameter and designates a queue that doesn't prioritize locations.
Amazon GameLift continues to retry each placement request until it reaches the queue's timeout setting. If a request times out, you can resubmit the request to the same queue or try a different queue.
Request Syntax
{
"DesiredPlayerSessions": [
{
"PlayerData": "string
",
"PlayerId": "string
"
}
],
"GameProperties": [
{
"Key": "string
",
"Value": "string
"
}
],
"GameSessionData": "string
",
"GameSessionName": "string
",
"GameSessionQueueName": "string
",
"MaximumPlayerSessionCount": number
,
"PlacementId": "string
",
"PlayerLatencies": [
{
"LatencyInMilliseconds": number
,
"PlayerId": "string
",
"RegionIdentifier": "string
"
}
],
"PriorityConfigurationOverride": {
"LocationOrder": [ "string
" ],
"PlacementFallbackStrategy": "string
"
}
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
Note
In the following list, the required parameters are described first.
- GameSessionQueueName
-
Name of the queue to use to place the new game session. You can use either the queue name or ARN value.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 256.
Pattern:
[a-zA-Z0-9-]+|^arn:.*:gamesessionqueue\/[a-zA-Z0-9-]+
Required: Yes
- MaximumPlayerSessionCount
-
The maximum number of players that can be connected simultaneously to the game session.
Type: Integer
Valid Range: Minimum value of 0.
Required: Yes
- PlacementId
-
A unique identifier to assign to the new game session placement. This value is developer-defined. The value must be unique across all Regions and cannot be reused.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 48.
Pattern:
[a-zA-Z0-9-]+
Required: Yes
- DesiredPlayerSessions
-
Set of information on each player to create a player session for.
Type: Array of DesiredPlayerSession objects
Required: No
- GameProperties
-
A set of key-value pairs that can store custom data in a game session. For example:
{"Key": "difficulty", "Value": "novice"}
.Type: Array of GameProperty objects
Array Members: Maximum number of 16 items.
Required: No
- GameSessionData
-
A set of custom game session properties, formatted as a single string value. This data is passed to a game server process with a request to start a new game session. For more information, see Start a game session.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 262144.
Required: No
- GameSessionName
-
A descriptive label that is associated with a game session. Session names do not need to be unique.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 1024.
Required: No
- PlayerLatencies
-
A set of values, expressed in milliseconds, that indicates the amount of latency that a player experiences when connected to Amazon Web Services Regions. This information is used to try to place the new game session where it can offer the best possible gameplay experience for the players.
Type: Array of PlayerLatency objects
Required: No
- PriorityConfigurationOverride
-
A prioritized list of locations to use for the game session placement and instructions on how to use it. This list overrides a queue's prioritized location list for this game session placement request only. You can include Amazon Web Services Regions, local zones, and custom locations (for Anywhere fleets). You can choose to limit placements to locations on the override list only, or you can prioritize locations on the override list first and then fall back to the queue's other locations if needed. Choose a fallback strategy to use in the event that Amazon GameLift fails to place a game session in any of the locations on the priority override list.
Type: PriorityConfigurationOverride object
Required: No
Response Syntax
{
"GameSessionPlacement": {
"DnsName": "string",
"EndTime": number,
"GameProperties": [
{
"Key": "string",
"Value": "string"
}
],
"GameSessionArn": "string",
"GameSessionData": "string",
"GameSessionId": "string",
"GameSessionName": "string",
"GameSessionQueueName": "string",
"GameSessionRegion": "string",
"IpAddress": "string",
"MatchmakerData": "string",
"MaximumPlayerSessionCount": number,
"PlacedPlayerSessions": [
{
"PlayerId": "string",
"PlayerSessionId": "string"
}
],
"PlacementId": "string",
"PlayerLatencies": [
{
"LatencyInMilliseconds": number,
"PlayerId": "string",
"RegionIdentifier": "string"
}
],
"Port": number,
"PriorityConfigurationOverride": {
"LocationOrder": [ "string" ],
"PlacementFallbackStrategy": "string"
},
"StartTime": number,
"Status": "string"
}
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- GameSessionPlacement
-
Object that describes the newly created game session placement. This object includes all the information provided in the request, as well as start/end time stamps and placement status.
Type: GameSessionPlacement object
Errors
For information about the errors that are common to all actions, see Common Errors.
- InternalServiceException
-
The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.
HTTP Status Code: 500
- InvalidRequestException
-
One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.
HTTP Status Code: 400
- NotFoundException
-
The requested resources was not found. The resource was either not created yet or deleted.
HTTP Status Code: 400
- UnauthorizedException
-
The client failed authentication. Clients should not retry such requests.
HTTP Status Code: 400
- UnsupportedRegionException
-
The requested operation is not supported in the Region specified.
HTTP Status Code: 400
Examples
Request a new game session placement with player latency data
This example starts a new game session placement. The request calls for player sessions for two players, and provides each player's latency data for two Regions.
Amazon GameLift uses the latency data provided to determine what order to use when looking for a fleet to host the new game session. It does this by calculating the average player latency for each Region and ordering the queue's destinations starting with the lowest average latency. If the queue "matchmaker-queue" has a latency policy, however, things may change. For example, let's say matchmaker-queue has a policy that caps latency at 130 milliseconds for 60 seconds, followed by no cap. In this scenario, using the sample request below, the following sequence plays out:
-
Amazon GameLift calculates average latency for each Region:
us-east-1
= 110 andus-west-2
= 100. -
Amazon GameLift reorders the queue's destinations based on lowest average latency, and prioritizes destinations in Region
us-west-2
. -
The queue has a latency cap of 130 ms in force for the first 60 seconds of a placement. Amazon GameLift looks for any individual latency values that are greater than 130 ms. There is one: Player 2 reports a 150 ms latency when connected to Region
us-west-2
. As a result, Amazon GameLift temporarily drops allus-west-2
fleets as valid destinations. -
Amazon GameLift tries to place the new game session on fleets in Region
us-east-1
, followed by fleets in Regions with no latency information (if any). If available resources are found, the game session is placed and the request fulfilled. -
If no available resources are found, Amazon GameLift starts a new round of placement attempts, restarting at step 3. If 60 seconds have passed and the latency policy is no longer in force, then fleets in Region
us-west-2
are once more valid destinations -- and are preferred based on their low average latency. -
Amazon GameLift continues to attempt to place the new game session until it is successful or until the queue's timeout limit is reached.
Sample Request
{
"DesiredPlayerSessions": [
{ "PlayerData": "level:10", "PlayerId": "player1" },
{ "PlayerData": "level:11", "PlayerId": "player2" }
],
"GameProperties": [
{ "Key": "map", "Value": "winter" }
],
"GameSessionName": "matchmaker-1234567890",
"GameSessionQueueName": "matchmaker-queue",
"MaximumPlayerSessionCount": 4,
"PlacementId": "Place-12345",
"PlayerLatencies": [
{ "LatencyInMilliseconds": 100, "PlayerId": "player1", "RegionIdentifier": "us-east-1" },
{ "LatencyInMilliseconds": 50, "PlayerId": "player1", "RegionIdentifier": "us-west-2" },
{ "LatencyInMilliseconds": 120, "PlayerId": "player2", "RegionIdentifier": "us-east-1" },
{ "LatencyInMilliseconds": 150, "PlayerId": "player2", "RegionIdentifier": "us-west-2" }
]
}
Request a game session placement with priority configuration override
This example requests a game session placement using an alternate list of location priorities.
Amazon GameLift uses the priority configuration override to change how it searches a
queue's destinations when looking for a resource to host the new game session.
The queue "custom-locations" has a PriorityConfiguration
setting
that prioritizes locations first and includes a prioritized location list. For
this one placement request only, that list is overridden with the list in
PriorityConfigurationOverride. The following sequence
plays out:
-
Amazon GameLift looks for the first location on the override list (
us-west-2
) in each destination in the queue, using the queue's destination priority order. In each fleet location, it searches for an available hosting resource. When one is found, the game session is placed and the request fulfilled. -
If no available resources are found in the first location, Amazon GameLift looks at destinations for the next location on the override list. and so on. As soon as an available resource is found, the game session is placed and the search stops.
-
If Amazon GameLift searches all locations on the override list and finds no available resources, the first placement pass has failed. Because this placement request specified no fallback strategy, Amazon GameLift doesn't look at any additional queue locations. The placement request remains in the queue and is processed again in turn until a placement succeeds or until the queue's timeout limit is reached.
Sample Request
{
"GameSessionName": "customlocations-1234567890",
"GameSessionQueueName": "custom-locations",
"MaximumPlayerSessionCount": 4,
"PlacementId": "Place-12345",
"PriorityConfigurationOverride": {
"LocationOrder": ["us-west-2", "us-east-1"],
"PlacementFallbackStrategy": "NONE"
}
}
See Also
For more information about using this API in one of the language-specific Amazon SDKs, see the following: