How to Set Up Game Servers

Overview

In this guide, we're going to walk you through the process of setting up a game server using our platform. After the game server is ready, we'll also show you how to implement our Dedicated Server Management (DSM), which can help and manage the servers used by our Matchmaking service.

Requirements

Have a server-build of your game ready.

Implementation

Create a Game Namespace

First, log in to our Admin Portal. (https://demo.accelbyte.io/admin). After logging in you'll be directed to Namespace list, or if you're already in the Admin Portal, go to the Namespace section on the left side of the dashboard menu bar and choose See all namespaces.

How to Configure Game Servers
Figure 1. Admin Portal - Dashboard
Enabling Game Servers
Figure 2. Admin Portal - Namespaces

Click the Create New button to create a new namespace. As an example, we input "lightfantastic" as our namespace for our sample game Light Fantastic created in Unity.

Creating Game Namespace
Figure 3. Admin Portal - Creating a Namespace

Create Client Credentials and Set Up Permissions

After creating your namespace, you need to create client credentials. To do this, go to the OAuth Clients menu in the Platform Configurations menu in the upper-right corner of the dashboard and hit the Create New button.

Game Platform Configuration
Figure 4. Admin Portal - Clients

You can set the Client Type as either Public or Confidential. Set the Client Type to Confidential. Then fill in the form as instructed, and select the Namespace that you created earlier to generate the Client ID and Client Secret. Save these as we are going to use these in our next config step. When you're ready to continue, hit Create.

Game Client Configuration
Figure 5. Admin Portal - Creating a New Client
Creating Your Own Game Client
Figure 6. Admin Portal - The Newly Created Client

Next we'll add permissions to our client credential. Click the client name and switch to the Permissions tab to set up the permission settings. Click the Add button and input NAMESPACE:{namespace}:DSM:SERVER into the Resource field. Then select the Update checkbox to update the permission and click Confirm.

Adding Permissions to Game Client
Figure 7. Admin Portal - Permissions Tab
Adding Permissions to Your Game Client
Figure 8. Admin Portal - Adding a New Permission

Now we have a working client credential with proper permissions ready to use.

Creating Game Client and Configuring Its Permissions
Figure 9. Admin Portal - The Newly Created Client Permission

Create a Matchmaking Channel / GameMode

To create a matchmaking channel, you can follow the instructions in our documentation.

After configuring your matchmaking rules (including the Flexing Rules), you can implement matchmaking in your game.

Setting Up the Game Config for the Game Server / Dedicated Server and Game Client

This setup is pretty straightforward. Set the AccelByte SDK config and make sure all of the config values are valid. Below are examples of configs for the game client and game server. Both of these examples are located in Assets/Resources/folder.

{
    "PublisherNamespace": "accelbyte",
    "Namespace": "lightfantastic",
    "UseSessionManagement": true,
    "BaseUrl": "https://sampleaddress.io",
    "LoginServerUrl": "https://sampleaddress.io",
    "IamServerUrl": "https://sampleaddress.io/iam",
    "PlatformServerUrl": "https://sampleaddress.io/platform",
    "BasicServerUrl": "https://sampleaddress.io/basic",
    "LobbyServerUrl": "wss://sampleaddress.io/lobby/",
    "CloudStorageServerUrl": "https://sampleaddress.io/binary-store",
    "TelemetryServerUrl": "https://sampleaddress.io/telemetry",
    "GameProfileServerUrl": "https://sampleaddress.io/soc-profile",
    "StatisticServerUrl": "https://sampleaddress.io/statistic",
    "ClientId": "clientid",
    "ClientSecret": "clientsecret",
    "RedirectUri": "http://127.0.0.1"
}
GitHub Gist link
{
  "PublisherNamespace": "accelbyte",
  "Namespace": "lightfantastic",
  "BaseUrl": "https://sampleaddress.io",
  "DSMServerUrl": "https://sampleaddress.io/dsm",
  "IamServerUrl": "https://sampleaddress.io/iam",
  "ClientId": "clientid",
  "ClientSecret": "clientsecret",
  "RedirectUri": "redirecturi"
}
GitHub Gist link

Create a Server Image Using Docker

Install Docker Desktop

To create a server image, you will need to install Docker. Here's how to install Docker on Windows.

  1. Install Docker Toolbox here.
  2. Install Docker Desktop for Windows here.
  3. After installation is complete, make sure you enable Hyper-V then restart your computer.
  4. To check if the Docker is working properly, use command prompt (cmd) or power shell to run docker version. If Docker is working properly, move on to the next step.

Build the Server Image

After Docker is installed, you need to build a Linux Server to an image. To do this, first you need to create a Dockerfile. A Dockerfile contains the config of the image, i.e. it contains a set of commands that need to run before the image can run in the container.

  1. Create a folder to work in. In this example, we made a folder named DSBuild.
  2. Inside the folder, create a file named Dockerfile without a file extension.
  3. Create one more folder for the Linux server build. We named our folder lightfantastic.
Game Dedicated Server Configuration
Figure 13a. Inside the DSBuild Folder
Create Your Own Dedicated Game Server
Figure 13b. Inside the lightfantastic Folder

4. Fill in the commands inside the Dockerfile.

Unity Sample Game Multiplayer - Game Dedicated Servers
Figure 13c. Inside the Dockerfile

5. The next step is to open cmd in the DSBuild folder and run the build command as follows:

docker build -t lightfantastic-server:latest -f "Dockerfile" lightfantastic

Wait a few moments while the command runs..

6. To verify that your image has been created, run the docker images command to see if the newly-created image is included in the list.

Upload the Image to AWS ECR

After your image is ready inside the docker, the next step is to push your image to your preferred cloud platform. For this example, we're using AWS.

  1. Create a repo on ECR, we named ours lightfantastic-server.
  2. Use AWS CLI to log in to AWS. Tag the image created earlier, then push it to the AWS ECR.
  3. Log in to AWS with the aws configure command. Fill in your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY along with the region you want to push the image to.
  4. Get the login token by using the following command. In this example, we're pushing to the us-west-2 region.
aws ecr get-login --no-include-email --region us-west-2

5. With the token information received from the previous command, run the command below:

docker login -u AWS -p <TOKEN> kiam

6. Tag your image using a generated number provided by the AWS ECR repo, using the following command:

docker tag lightfantastic-server:latest [generatednumber].dkr.ecr.us-west-2.amazonaws.com/lightfantastic-server:latest

Replace the [generatednumber] with the 12-digit generated number you get from the repo.

7. Push the tagged image to AWS ECR with this command:

docker push [generatednumbers].dkr.ecr.us-west-2.amazonaws.com/lightfantastic-server:latest

Create a New DSM Configuration in the Admin Portal

In order to configure AccelByte Dedicated Server Management (DSM), we use our AWS repository. The DSM Configuration settings can be found in our Admin Portal (https://demo.accelbyte.io/admin). Click on Dedicated Server Management from the menu and go to Configurations.

Easy Dedicated Servers Configuration
Figure 14a. Dedicated Server Configurations

Click the Add Configuration button to create a new configuration for the newly created game server. Below are our configuration values for our sample game Light Fantastic:

  • Port : 15937
    Port where your dedicated server is listening for a connection.
  • Min. Count : 0
    Minimum number of dedicated servers spawned regardless of the condition, whether they are idle or active.
  • Max. Count : 0
    Maximum number of dedicated servers allowed to be spawned.
  • Buffer Count : 0
    Default number of dedicated servers that should be ready.
  • CPU Request : 500m
    Minimum number of cores needed by the dedicated server. (1000m means 1 CPU core)
  • CPU Limit : 1000m
    Maximum number of cores that can be used by the dedicated server. (1000m means 1 CPU core)
  • Memory Request : 256Mi
    Minimum size of the memory needed by the dedicated server.
  • Memory Limit : 512Mi
    Maximum size of the memory that can be used by the dedicated server.
  • Creation Timeout : 120
    The time limit for a dedicated server to be created after being requested.
  • Claim Timeout : 60
    The time limit for the lobby service to claim a dedicated server after being requested.
  • Session Timeout : 300
    The time limit for an active session to finish.
  • Heartbeat Timeout : 30
    The time limit for a regitered dedicated server to call the heartbeat endpoint.
  • Unreachable Timeout : 3600
    The time limit for an unreachable dedicated server to call the heartbeat endpoint.

Adding Configurations to Game Dedicated Servers
Figure 14b. Adding a New Config for the DSM

After you configure your DSM, you can start matchmaking from your game client and get your game client connected to the game server with AccelByte services.


If you have any questions or are interested in learning more, we'd love to hear from you. Send us an email at support@accelbyte.io.