Using the Load Tester
In this section, we show you how to execute a load test on Run the DirectX Sample. You need two clusters to run the sample: One cluster runs the Genvid stack and the other executes the load test. Note that the load tester can also be run locally for development purpose.
See The AWS Cloud Environment for information about running your game in the cloud.
Important
If you deploy your Run the DirectX Sample in The Azure Cloud Environment, it is recommended to deploy your cluster with the SDK-{version}/basic/azurerm_basic_cluster_alb_ssl module. The basic/azurerm_basic_cluster_alb_ssl module supports load balancing, DNS, and SSL certificates. Make sure that the Node.js version you use is the one provided by the SDK (currently version 10.16.3).
This application sends metrics to statsd. You can use the TICK Stack Metrics to collect and see them.
Before You Begin
Although you can run the application locally for testing, we assume that you will run the load test on the cloud. We will use the Run the DirectX Sample for this demonstration. See Example: Building the DirectX Sample for the Cloud for more information on how to deploy this sample on the Cloud.
Edit the Configuration File
If you’re doing load testing, you have likely set up your system to have a public entry point,
either through a load balancer or a similar configuration. You can setup your client to use
the right configuration either by modifying the Configuration file, or
if you are using a more complex login protocol, by modifying the basic_session
function in
the app/src/cube_client.ts
source file. For example, in the cube sample, we have the
following code:
// Starts the connection to the services
start() {
fetch("/api/public/channels/join", {
method: "POST",
})
.then((data) => data.json())
.then((res) => {
if (res.name === "Error") {
genvid.error(`Failed getting stream info: ${res.message}. Retrying in ${this.fiboStartIterator.get()} seconds...`);
setTimeout(() => {
this.start();
this.fiboStartIterator.next();
}, this.fiboStartIterator.get() * 1000);
} else {
this.onChannelJoin(res);
}
})
.catch((error) => genvid.error(`Can't get the stream info: ${error}`));
}
which fetch the URL /api/public/channels/join
on the web server. In the cube_client.ts
,
we are using the value of the custom.loadtester.join_url
configuration key, which is set by default
to point to a localhost. It should instead point to the public URL of your
join call.
See also
Create the Test Cluster
The first step is to create a cluster to run your test clients. Although you could run the sample on the same cluster as your game, we recommend to do it in a different cluster, even on a different region. There will be additional costs associated with the load test activity but your results may be more representative of an actual game experience.
We will use the basic_cluster
cluster module for this but will only use the server and internal
instances.
Go to Bastion UI and create a cluster using the
basic/basic_cluster
module. Let call itloadtest
for this demonstration.Click the
infrastructure
link. (You can keep the default settings for now.)Click on the
Settings
menu.
# Set the instance_game_count
, instance_encoding_count
and instance_public_count
to 0.
- # Select a bigger instance for
instance_internal_type
, liket2.large
and increaseinstance_internal_count
if needed, depending on how many load tester instances you want to run.
Click on the
Commands
menu.Click Plan Apply, and if the result is good, Apply, and wait until it is done.
Initialize the Load-Test Cluster
It is now time to configure the test cluster. First, just initialize the cluster:
genvid-sdk -c loadtest setup
Note that you don’t need to run the genvid-sdk load-config-sdk
command on this cluster since
it will not run the SDK, only the loadtester client. Next, you can build and load the load tester
client.
py loadtester.py prepare # Install the genvid.js library and run npm install
py loadtester.py build-cloud
py loadtester.py -c loadtest upload-images --update-config
py loadtester.py -c loadtest load
Note
It is also recommended that you install a metric aggregation stack to collect the metrics on both clusters. You can use TICK Stack Metrics as a starting point:
py tick.py -c testcluster load
Run the Load-Test
You run the load tester by running this command:
genvid-sdk -c loadtest start
All jobs will be started but if you look at the Cluster UI’s Jobs screen, you will
see that the loadtester
job is dead. This is because its tasks count is 0. You can augment it manually from the
UI or run the follow command:
genvid-sdk -c loadtest set-taskgroup-count --step 1 --interval 5 loadtester 3
The --step
is the number of new tasks to spawn at a time, the --interval
is the interval in seconds between
each step. After that came the task name (loadtester
) and the target count. See the genvid-sdk tool for
more information.
Important
The number of loadtester you can run depends on the resources available on your clusters. If you can start more,
try adding more internal instances to your loadtest
cluster, or use bigger instances.