Worker connection limits
For each worker type, you can configure two types of worker connection limit:
- Rate limit. For example, a maximum of 10
MyWorkerType
workers can connect in a one-second window. - Max capacity. For example, the maximum number of
MyWorkerType
workers that can connect is 500.
You can configure these worker connection limits statically in a deployment’s launch configuration or dynamically while a deployment is running.
These configurations are optional and can be set independently. If not set, worker connections will default to unlimited rate and capacity.
Configuring connection limits in the deployment launch configuration
You can configure worker connection limits in the optional login_rate_limit
and connection_capacity_limit
fields inside a deployment’s launch configuration:
{
...
"workers": [{
"worker_type": "MyWorkerType",
"connection_capacity_limit": {
"max_capacity": 500
},
"login_rate_limit": {
"duration": "1s",
"requests_per_duration": 10
}
}],
...
}
In the example above, workers of type MyWorkerType
can have a maximum of 500 workers connected at a given time, and no more than 10 workers can connect in a given second.
For login_rate_limit
, the duration
field accepts a combination of hour h
, minute m
, and second s
. For example, you can set duration
to 1h30m20s
or 1h50s
.
Viewing connection limits
Since the connection limits are set in a deployment’s launch configuration, you can view their values wherever you can view this launch configuration, including downloading the launch configuration from the SpatialOS Console deployment overview page, or by checking the launch_config
field.
If a deployment is running, you can also view its worker connection limits in:
- the SpatialOS Console, on the deployment’s Config page, with the flag name
login_v2_config_json
- the
Deployment
object’sworker_connection_capacities
andworker_connection_rate_limits
fields.
For example, you can use the Platform SDK to make a GetDeployment request on a live deployment:
var liveDeploymentResponse = _deploymentServiceClient.GetDeployments(
new GetDeploymentsRequest {
Id = LiveDeploymentId,
ProjectName = ProjectName,
}
);
You can then access the worker_connection_capacities
and worker_connection_rate_limits
fields:
var liveDeployment = liveDeploymentResponse.Deployment;
Console.WriteLine($"Worker connection capacities: {liveDeployment.WorkerConnectionCapacities}");
Console.WriteLine($"Worker connection rate limits: {liveDeployment.WorkerConnectionRateLimits}");
Changing connection limits at runtime
You can use the Platform SDK to add, update, or remove connection limits while a deployment is running. The updated limits are only applied to the running deployment and not to any subsequent deployments.
For example, if in the deployment launch configuration MyWorkerType
has connection_capacity_limit
set to max_capacity
100, and while the deployment is running we update max_capacity
to 50, then if we restart this deployment, max_capacity
will revert to 100 (the value inside the deployment launch configuration).
For connection_capacity_limit
, you can set max_capacity
to a number that is smaller than the number of currently connected workers. For example, if there are already 120 workers of type MyWorkerType
connected, you can still set max_capacity
to 100. In this case, no more workers of type MyWorkerType
can connect until the count drops to below 100. The system does not disconnect any existing live workers.
Viewing connection limit metrics
You can view number of workers connected or being limited by looking at worker metrics.