Getting Started Concepts The Things Stack Cloud The Things Stack Enterprise Integrations API Hardware
Get The Things Stack

The Things Stack Enterprise

    Overview
  • AWS
  • Kubernetes
  • Docker
  • The Things Join Server
  • Manage The Things Stack
    • Configuration
    • Rate Limiting
    • Resource Limiting
    • Setting up billing with Stripe
    • Tenant Management
New in 3.14.2

Resource Limiting

The Things Stack supports setting maximum limits for active resources. Access to each resource is limited by a unique identifier key, and it is possible to define resource limiting classes for fine-grained control.

Example configuration

The resource limiting configuration is split into multiple profiles. For each profile, we provide a name and the maximum number of concurrent resources allowed rate. The profile is associated with a number of resource limiting classes. Refer to the Limited Entities section below for a list of all available resource limiting classes and what they mean.

Enable resource limiting by adding the following configuration to your ttn-lw-stack.yml.

Resource limiting can be applied per application, as well as for all applications in a tenant. The values shown below are only meant as an example. Make sure to adjust them accordingly, depending on the actual traffic of your deployment.

resource-limiting:
  profiles:
    - name: Limit application data plane connections (MQTT and gRPC)
      max-concurrent: 50
      associations:
        - as:conn
    - name: Override limit for application `test-app-1` of tenant `test-tenant-1`
      max-concurrent: 100
      associations:
        - as:conn:app:test-app-1@test-tenant-1
    - name: Override limit for all applications of tenants `test-tenant-2` and `test-tenant-3`
      max-concurrent: 200
      associations:
        - as:conn:tenant:test-tenant-2
        - as:conn:tenant:test-tenant-3

Limited Entities

Application Server Data Plane Connections

DescriptionLimit number of concurrent Application Server data plane connections by application and frontend.
Classesas:conn:app:{{ AppUID }}</code> <code>as:conn:tenant:{{ TenantID }}</code> <code>as:conn:frontend:{{ Frontend }}</code> <code>as:conn
Keyas:conn:frontend:{{ Frontend }}:app:{{ AppUID }}
Exampleas:conn:frontend:mqtt:app:app-1@tenant-1

For resources where multiple classes are defined, the first matching profile will be used. For example, if profile A is associated with class as:conn and profile B is associated with as:conn:app:my-application@my-tenant, then connections for my-application@my-tenant will use the limits from profile B.

Resource Limiting Actions

The following table describes how The Things Stack reacts when the maximum resource limits are exceeded.

Resource Resource Limit Action Expected Client Action
gRPC Application Connections Calls to Subscribe RPC will fail with an error of type ResourceExhausted. Terminate existing connections and retry.
MQTT Application Connections A ServerUnavailable response is returned for new connections. Terminate existing connections and retry.

For example, if an MQTT connection is failing due to resource limits exceeding, you will see an error such as Resource limit 16 exceeded for resource with key as:conn:frontend:mqtt:app:test-app-1@test-tenant-1. The resolution would be to terminate existing connections and retry.

External configuration

It is possible to load extra resource limiting profiles from an external file. Create a file named /opt/config/resource-limiting.yml (replace /opt/config with any path you like) with the following contents:

# If a profile is configured in `ttn-lw-stack.yml` for `as:conn`, then
# it will be overriden
profiles:
  - name: Example profile
    max-concurrent: 5
    associations: [as:conn]

Then add the following config to ttn-lw-stack.yml (replace /opt/config with your path):

resource-limiting:
  # This will read profiles from /opt/config/resource-limiting.yml
  config-source: directory
  directory: /opt/config
← Rate Limiting Setting up billing with Stripe →

On this page

  • Example configuration
  • Limited Entities
  • Resource Limiting Actions
  • External configuration

Sections

Getting Started

Concepts

The Things Stack Cloud

The Things Stack Enterprise

Integrations

API

Hardware

Sitemap

View our Sitemap

Contributing

GitHub

About Us

The Things Industries