

# Create a hosting fleet for Amazon GameLift Servers Realtime
<a name="realtime-fleets-creating"></a>

When you're ready to deploy Realtime servers for your game, create an Amazon GameLift Servers managed EC2 fleet. This topic assumes you've completed the following steps: 
+ Created a Realtime script that's configured for your game. See [Customize an Amazon GameLift Servers Realtime script](realtime-script.md).
+ Uploaded your Realtime script to Amazon GameLift Servers. See [Upload a script for Amazon GameLift Servers Realtime servers](realtime-script-uploading.md). 

**To create a managed EC2 fleet**

Use either the Amazon GameLift Servers console or the Amazon Command Line Interface (Amazon CLI) to create a managed EC2 fleet. If you're exploring the Realtime servers feature or want to get your servers up and running fast, follow the guidance for a minimal fleet configuration.

------
#### [ Console ]

**To create a managed EC2 fleet**

1. In the [Amazon GameLift Servers console](https://console.amazonaws.cn/gamelift/), in the navigation pane, choose **Fleets**.

1. On the **Fleets** page, choose **Create fleet**.

1. Choose **Managed EC2**.

1. On the **Fleet details** page do the following:

   1. For **Name**, enter a fleet name. We recommend including the fleet type (Spot or On-demand) in your fleet names. This makes it much easier to identify fleet types when viewing a list of fleets.

   1. For **Description**, provide a short description of the fleet.

   1. For **Binary type**, select **Script** to identify the type of game server to deploy to this fleet.

   1. Select a **Script** from the dropdown list of previously uploaded Realtime scripts.

1. (Optional) Under **Additional details** for the following:

   1. For **Instance role**, specify an IAM role that authorizes applications in your game build to access other Amazon resources in your account. For more information, see [ Communicate with other Amazon resources from your fleets](https://docs.amazonaws.cn/gameliftservers/latest/developerguide/gamelift-sdk-server-resources.html). To create a fleet with an instance role, your account must have the IAM `PassRole` permission. For more information, see [ IAM permission examples for Amazon GameLift Servers](https://docs.amazonaws.cn/gameliftsevers/latest/developerguide/gamelift-iam-policy-examples.html).

      You can't update these settings after fleet creation.

   1. For **Metric group**, Enter the name of a new or existing fleet metric group. You can aggregate the metrics for multiple fleets by adding them to the same metric group.

      You can't update the metric group after fleet creation.

1. Choose **Next**.

1. On the **Select locations** page, select one or more additional remote locations to deploy instances to. The home Region is automatically selected based on the Region you are accessing the console from. If you select additional locations, fleet instances are also deployed in these locations. 
**Important**  
To use Regions that aren't enabled by default, enable them in your Amazon Web Services account.  
Fleets with Regions that aren't enabled that you created before February 28, 2022 are not affected by this requirement.
To create new multi-location fleets or to update existing multi-location fleets, first enable any Regions or Local Zones that you choose to use.
For more information about Regions that aren't enabled by default and how to enable them, see [Managing Amazon Web Services Regions](https://docs.amazonaws.cn/general/latest/gr/rande-manage.html) in the *Amazon Web Services General Reference*. See [Getting started with Local Zones](https://docs.amazonaws.cn/local-zones/latest/ug/getting-started.html) in the *Amazon Local Zones User Guide*.

1. Choose **Next**.

1. On the **Define instance details page**, choose 

   1. **On-demand** or **Spot** instances for this fleet. For more information about fleet types, see [ On-Demand Instances versus Spot Instances](https://docs.amazonaws.cn/gameliftservers/latest/developerguide/gamelift-compute.html#gamelift-compute-spot). 

   1. From the **Filter architecture** menu choose **x64** or **Arm**. 
**Note**  
Graviton Arm instances require a server build for a Linux AMI. Server SDK 5.1.1 or newer is required for C\+\+ and C\#. Server SDK 5.0 or newer is required for Go. These instances do not provide out-of-the-box support for Mono installation on Amazon Linux 2023 (AL2023) or Amazon Linux 2 (AL2). 

       For information on Amazon EC2 Arm architectures, see [Amazon Graviton Processor](https://aws.amazon.com/ec2/graviton/) and [Amazon EC2 instance types](https://aws.amazon.com/ec2/instance-types/). 

   For information on the instance types supported by Amazon GameLift Servers, see the `EC2InstanceType` values under [CreateFleet() request parameters](https://docs.amazonaws.cn/gameliftservers/latest/apireference/API_CreateFleet.html#API_CreateFleet_RequestParameters). 

1. Select an Amazon EC2 **Instance type** from the list. For more information about choosing an instance type, see [ Instance types](https://docs.amazonaws.cn/gameliftservers/latest/developerguide/gamelift-compute.html#gamelift-compute-instance). 

   After you create the fleet, you can't change the instance type.

1. Choose **Next**.

1. On the **Configure runtime** page, under **Runtime configuration** do the following:

   1. For **Launch path**, enter the path to the server script. Example: **MyRealtimeLaunchScript.js**.

   1. For **Concurrent processes**, choose the number of server processes to run concurrently on each instance in the fleet. Review the Amazon GameLift Servers [limits](http://www.amazonaws.cn//ec2/faqs/#Is_Amazon_EC2_used_in_conjunction_with_Amazon_S3) on number of concurrent server processes. 

      Limits on concurrent server processes per instance apply to the total of concurrent processes for all configurations. If you configure the fleet to exceed the limit, the fleet can't activate.

1. Under **Game session activation**, provide limits for activating new game sessions on the instances in this fleet:

   1. For **Max concurrent game session activation**, enter the number of game sessions on an instance that activate at the same time. This limit is useful when launching multiple new game sessions may have an impact on the performance of other game sessions running on the instance.

   1. For **New activation timeout**, enter how long to wait for a session to activate. If the game session doesn't move to `ACTIVE` status before the timeout, Amazon GameLift Servers terminates the game session activation. 

1. (Optional) Under **EC2 port settings**, do the following:

   1. Choose **Add port setting** to define access permissions for inbound traffic connecting to the server process deployed on the fleet.

   1. For **Type**, choose **Custom TCP** or **Custom UDP**.

   1. For **Port range**, Enter a range of port numbers that allow inbound connections. A port range must use the format `nnnnn[-nnnnn]`, with values between 1026 and 60000. Example: **1500** or **1500-20000**. 

   1. For **IP address range**, Enter a range of IP addresses. Use CIDR notation. Example: **0.0.0.0/0** (This example allows access to anyone trying to connect.)

1. (Optional) Under **Game session resource settings** do the following:

   1. For **Game scaling protection policy**, Turn on or off scaling protection. Amazon GameLift Servers won't terminate instance with protection during a scale down event if they're hosting an active game session.

   1. For **Resource creation limit**, enter a maximum number of game sessions a player can create during the policy period.

1. Choose **Next**.

1. (Optional) Add tags to the build by entering **Key** and **Value** pairs. Choose **Next** to continue to fleet creation review.

1. Choose **Create**. Amazon GameLift Servers assigns an ID to the new fleet and begins the fleet activation process. You can track the new fleet's status on the **Fleets** page. 

You can update the fleet's metadata and configuration at any time, regardless of fleet status. For more information, see [ Update an Amazon GameLift Servers fleet configuration](https://docs.amazonaws.cn/gameliftservers/latest/developerguide/fleets-editing.html). You can update fleet capacity after the fleet has reached ACTIVE status. For more information, see [ Scaling game hosting capacity with Amazon GameLift Servers](https://docs.aws.amazon.com/gameliftservers/latest/developerguide/fleets-manage-capacity.html). 

You can also add or remove remote locations.

------
#### [ Amazon CLI ]

Use the [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/gamelift/create-fleet.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/gamelift/create-fleet.html) command to create a fleet of compute type `EC2`. Amazon GameLift Servers creates the fleet resource in your current default Amazon Web Services Region (or you can add a --region tag to specify a different Amazon Web Services Region).

**Create a minimal managed fleet**

The following example request creates a new fleet with the minimal settings that are required to deploy a fleet with running game servers that game clients can connect to. The new fleet has these characteristics: 
+ It specifies a Realtime server script, which is uploaded to Amazon GameLift Servers and in `READY` status.
+ Is uses c5.large On-Demand Instances.
+ It sets the fleet's home Amazon Web Services Region to `us-west-2` and deploys instances to that Region only.
+ Based on the runtime configuration, each instance in the fleet runs one game server process, which means that each instance can host only one game session at a time. By default, game session activation timeout is set to 300 seconds, with no limit on the number of concurrent activations.
+ Players can connect to game servers using port `33435`.
+ All other features are either turned off or use default settings.

```
aws gamelift create-fleet \
    --name MinimalRealtimeFleet123 \
    --description "A basic test fleet" \
    --region us-west-2 \
    --ec2-instance-type c5.large \
    --fleet-type ON_DEMAND \
    --script-id script-1111aaaa-22bb-33cc-44dd-5555eeee66ff \
    --runtime-configuration "ServerProcesses=[{LaunchPath=/local/game/megafrograce.js, ConcurrentExecutions=1}]" \
    --ec2-inbound-permissions "FromPort=33435,ToPort=33435,IpRange=0.0.0.0/0,Protocol=UDP"
```

**Create a fully configured managed fleet**

The following example request creates a production fleet with settings for all optional features. The new fleet has these characteristics: 
+ It specifies a Realtime server script, which has been uploaded to Amazon GameLift Servers and is in `READY` status.
+ It uses c5.large On-Demand Instances with the operating system that matches the selected game build. 
+ It sets the fleet's home Amazon Web Services Region to `us-west-2` and deploys instances to the home Region and one remote location `sa-east-1`. 
+ Based on the runtime configuration: 
  + Each compute in the fleet runs 10 game server processes with the same launch parameters, which means that each compute can host up to 10 game sessions simultaneously. 
  + On each compute, only two game sessions can be activating at the same time. Activating game sessions must be ready to host players within 300 seconds (5 minutes) or be terminated.
+ Players can connect to game servers using a port in the following range `33435 to 33535`.
+ All game sessions in the fleet have game session protection turned on.
+ Individual players are limited to creating three new game sessions within a 15-minute period.
+ Metrics for this fleet are included in the metric group `AMERfleets`, which (for this example) aggregates metrics for a group of fleets in North, Central, and South America. 

```
aws gamelift create-fleet \
    --name ProdRealtimeFleet123 \
    --description "A fully configured prod fleet" \
    --ec2-instance-type c5.large \
    --region us-west-2 \
    --locations "Location=sa-east-1" \
    --fleet-type ON_DEMAND \
    --script-id script-1111aaaa-22bb-33cc-44dd-5555eeee66ff \
    --certificate-configuration "CertificateType=GENERATED" \
    --runtime-configuration "GameSessionActivationTimeoutSeconds=300, MaxConcurrentGameSessionActivations=2, ServerProcesses=[{LaunchPath=/local/game/megafrograce.js, ConcurrentExecutions=10}]" \
    --new-game-session-protection-policy "FullProtection" \
    --resource-creation-limit-policy "NewGameSessionsPerCreator=3, PolicyPeriodInMinutes=15" \
    --ec2-inbound-permissions "FromPort=33435,ToPort=33535,IpRange=0.0.0.0/0,Protocol=UDP" \
    --metric-groups  "AMERfleets"
```

If the create-fleet request is successful, Amazon GameLift Servers returns a set of fleet attributes that includes the configuration settings you requested and a new fleet ID. Amazon GameLift Servers then initiates the fleet activation process and sets the fleet status and the location statuses to **New**. You can track the fleet's status and view other fleet information using these CLI commands: 
+ [describe-fleet-events](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-events.html)
+ [describe-fleet-attributes](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-attributes.html)
+ [describe-fleet-capacity](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-capacity.html)
+ [describe-fleet-port-settings](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-port-settings.html)
+ [describe-fleet-utilization](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-utilization.html)
+ [describe-runtime-configuration](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-runtime-configuration.html)
+ [describe-fleet-location-attributes](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-location-attributes.html)
+ [describe-fleet-location-capacity](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-location-capacity.html)
+ [describe-fleet-location-utilization](https://docs.amazonaws.cn/cli/latest/reference/gamelift/describe-fleet-location-utilization.html)

You can change the fleet's capacity and other configuration settings as needed using these commands:
+ [update-fleet-attributes](https://docs.amazonaws.cn/cli/latest/reference/gamelift/update-fleet-attributes.html)
+ [update-fleet-capacity](https://docs.amazonaws.cn/cli/latest/reference/gamelift/update-fleet-capacity.html)
+ [update-fleet-port-settings](https://docs.amazonaws.cn/cli/latest/reference/gamelift/update-fleet-port-settings.html)
+ [update-runtime-configuration](https://docs.amazonaws.cn/cli/latest/reference/gamelift/update-runtime-configuration.html)
+ [create-fleet-locations](https://docs.amazonaws.cn/cli/latest/reference/gamelift/create-fleet-locations.html)
+ [delete-fleet-locations](https://docs.amazonaws.cn/cli/latest/reference/gamelift/delete-fleet-locations.html)

------