Load Balancer Guide

The current version of the Load Balancer comes with the source code and an example that showcases the load balancing functionality in Unity. In order to run the basic example, you must install the corresponding executables and dependencies required for its operation. The source code can be used as a standalone solution to implement the custom load balancer. This guide will walk you through the installation process and running the basic Load Balancer example.

For more information about the Load Balancer, refer to the corresponding article explaining the load balancing mechanism.

Installation

  1. Clone the Load Balancer repository to your local environment:

https://github.com/gamecarrier/load-balancer

  1. Download and install Visual Studio 2022.

While installing the Visual Studio 2022, make sure to include two additional components:

- .NET desktop development
- Game development with Unity

vs_components

  1. Download and install .NET Runtime 6.0.

  2. Download and install .NET SDK 6.0.

  3. Sign up with the Game Carrier, log into your account, on the Download page in the dashboard select the appropriate platform and download the Transport Server and client binaries.

gc_binaries

Run the installation after the download.

  1. Additionally, you have to download the license file authentication.dat by clicking the Download auth file for... button in the Download section of the dashboard.

license_file

Once downloaded, move this file to the .gc folder in the user home directory:

/home/{username}/.gc
C:\Users{username}.gc\
/Users/{username}/.gc
  1. Open the Load Balancer solution in the Visual Studio 2022. The solution is located in the cloned repository /lb/src/LoadBalancer.sln.

  2. Set the LoadBalancer.Server as the Startup Project.

startup_project

At this point you can run the Load Balancer server to conduct further experiments.

Running Unit Tests

To make sure that all underlying functionality works properly you can run a few unit tests.

Run the Load Balancer server by selecting the LoadBalancer.Server from the Search Solutions Explorer and clicking the Run button.

run_lb_server

The correct execution of the LoadBalancer.Server will open a separate terminal window for logging purposes.

running_server

Open Test Explorer by clicking the Test dropdown menu and selecting the Test Explorer from the list.

test_explorer

Either run All Tests or select a specific test from the list and run it.

run_tests

Running Unity Example

This section implies that you have Unity Hub installed with the Unity version 2020.3.48f1.

The UnityFPS example allows showcasing the process of a client interacting with the Load Balancer to connect to the game, this process involves the following steps:

  1. Connecting to the Authentication Server.
  2. Obtaining the authentication token.
  3. Retrieving the list of Jump Servers from the Authentication Server. The list contains the IP addresses and ports of Jump Servers.
  4. The client selects the Jump Server that has the lowest latency.
  5. The client connects to the Jump Server.
  6. The Jump Server verifies the authentication token.
  7. The client requests the Jump Server to provide a list containing the IP addresses and ports of the Game Servers.
  8. The client connects to the Game Server.
  9. The Game Server verifies the authentication token.
  10. The scene and other details get loaded.

To run the UnityFPS example you have to go through a set of required steps:

Run the Load Balancer server by selecting the LoadBalancer.Server from the Search Solutions Explorer and clicking the Run button.

run_lb_server

The correct execution of the LoadBalancer.Server will open a separate terminal window for logging purposes.

running_server

Run the script CopyClientToUnityFPS.cmd to copy all necessary files to Unity. The script is located in the cloned repository \lb\src\cmd\CopyClientToUnityFPS.cmd.

Once the script is executed, run the Unity Hub where you will find the newly added UnityFPS project. Click it to run the project.

unity_example

In the UnityFPS project open the Scenes folder.

unity_example_2

In the folder select the Start.unity file and run the scene.

unity_example_3

Click the Join Room button in scene Display:

unity_example_4

By clicking this button, you instruct the client to perform all steps requierd for a client to connect to a game server through the Load Balancer. This process is described in the beggining of this section.

The correct execution of the client logic will run the following scene, while outputting the connection history:

unity_example_5