Skip to main content
Version: 2.3.2

Tenant Resource Limitation

Currently, the resource isolation of CnosDB is tenant-level. There are two types of restrictions: one is to limit the objects created by tenants; One is to limit the size and number of times tenants can read and write data. Both types of restrictions can be set using the same SQL that can be used only by the most privileged users.

Syntax

alter tenant <tenant_name> set _limiter '<limiter_json>';

Parameters

  • tenant_name: The name of the tenant to be set.
  • limiter_json: The content of tenant resource limit, specifically classified as: object limit object_config and read and write limit request_config, content format must be json format.

object_config, object limit, the parameters included are as follows:

Parameter nameDescriptionRequiredMetric
max_users_numberSpecifies the maximum number of users (members) to be a tenant; when set to null, it is unbounded.Yesone
max_databasesSpecifies the maximum number of databases for each tenant; when set to null, it is unlimited.Yesone
max_shard_numberSpecifies the maximum number of shards that can be created in a tenant's database; when set to null, this is unlimited.Yesone
max_replica_numberSpecifies the maximum number of replicas that can be created for the database under the tenant; when set to null, this is unlimited.Yesone
max_retention_timeSpecifies the maximum TTL parameter of the database under the tenant. When null, it is unlimited.YesDay

Example:

"object_config": {
"max_users_number": 1,
"max_databases": 3,
"max_shard_number": 2,
"max_replicate_number": 2,
"max_retention_time": 30
},

request_config, read and write limit, the parameters included are as follows:

Parameter nameDescriptionRequiredMetric
data_inLimit the size of write requests over a period of time; when set to null, it is unbounded.YesByte
data_outLimit the size of read requests over a period of time; when set to null, it is unbounded.YesByte
queriesLimit the number of read requests in a time.Set to null indicates no limit.YesTime
writesLimit the number of write requests in a time.When set to null, it is unlimited.YesTime

The data_in and data_out limits are implemented by the token bucket algorithm and consist of two parts: One is a remote token bucket on meta, specified by remote_bucket, and the other is a local token bucket on data, specified by local_bucket, where tokens are measured in bytes.

Parameters of remote_bucket are as follows:

Parameter nameDescriptionMetric
maxLimit the maximum number of tokens in a bucketone
initialLimit the number of tokens in the initial bucketone
refillLimit the number of tokens populated at a timeone
intervalTime interval to fill the tokenms

Parameters of local_bucket are as follows:

Parameter nameDescriptionMetric
maxLimit the maximum number of tokens in a bucketone
initialLimit the number of tokens in the initial bucketone

The following example bucket setup allows 10KB of data to be written every 100ms and 10KB of data to be cased every 100ms;

Example data writing settings

"data_in": {
"remote_bucket": {
"max": 10000,
"initial": 0,
"refill": 10000,
"interval": 100
},
"local_bucket": {
"max": 10000,
"initial": 0
}
},
"data_out": {
"remote_bucket": {
"max": 10000,
"initial": 0,
"refill": 10000,
"interval": 100
},
"local_bucket": {
"max": 100,
"initial": 0
}
}

An example of limiting the size and number of reads and writes to a tenant is as follows:

"request_config": {
"data_in": {
"remote_bucket": {
"max": 10000,
"initial": 0,
"refill": 10000,
"interval": 100
},
"local_bucket": {
"max": 10000,
"initial": 0
}
},
"data_out": {
"remote_bucket": {
"max": 100,
"initial": 0,
"refill": 100,
"interval": 100
},
"local_bucket": {
"max": 100,
"initial": 0
}
},
"queries": null,
"writes": null
}

Overall Example

alter tenant cnosdb set _limiter = '{
"object_config": {
"max_users_number": 1,
"max_databases": 3,
"max_shard_number": 2,
"max_replicate_number": 2,
"max_retention_time": 30
},
"request_config": {
"data_in": {
"remote_bucket": {
"max": 10000,
"initial": 0,
"refill": 10000,
"interval": 100
},
"local_bucket": {
"max": 10000,
"initial": 0
}
},
"data_out": {
"remote_bucket": {
"max": 100,
"initial": 0,
"refill": 100,
"interval": 100
},
"local_bucket": {
"max": 100,
"initial": 0
}
},
"queries": null,
"writes": null
}
}';