StartGameSessionPlacement
Places a request for a new game session in a queue. When processing a placement request, Amazon GameLift searches for available resources on the queue's destinations, scanning each until it finds resources or the placement request times out.
A game session placement request can also request player sessions. When a new game session is successfully created, Amazon GameLift creates a player session for each player included in the request.
When placing a game session, by default Amazon GameLift tries each fleet in the order they are listed in the queue configuration. Ideally, a queue's destinations are listed in preference order.
Alternatively, when requesting a game session with players, you can also provide latency data for each player in relevant Regions. Latency data indicates the performance lag a player experiences when connected to a fleet in the Region. Amazon GameLift uses latency data to reorder the list of destinations to place the game session in a Region with minimal lag. If latency data is provided for multiple players, Amazon GameLift calculates each Region's average lag for all players and reorders to get the best game play across all players.
To place a new game session request, specify the following:
-
The queue name and a set of game session properties and settings
-
A unique ID (such as a UUID) for the placement. You use this ID to track the status of the placement request
-
(Optional) A set of player data and a unique player ID for each player that you are joining to the new game session (player data is optional, but if you include it, you must also provide a unique ID for each player)
-
Latency data for all players (if you want to optimize game play for the players)
If successful, a new game session placement is created.
To track the status of a placement request, call DescribeGameSessionPlacement and check the request's status. If the status
is FULFILLED
, a new game session has been created and a game session ARN
and Region are referenced. If the placement request times out, you can resubmit the
request or retry it with 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
"
}
]
}
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 @aws; 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
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,
"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
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
POST / HTTP/1.1
Host: gamelift.us-west-2.amazonaws.com;
Accept-Encoding: identity
Content-Length: 824
User-Agent: aws-cli/1.11.36 Python/2.7.9 Windows/7 botocore/1.4.93
Content-Type: application/x-amz-json-1.0
Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20170406/us-west-2/gamelift/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
X-Amz-Date: 20170406T004805Z
X-Amz-Target: GameLift.StartGameSessionPlacement
{
"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" },
]
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: