Resource Groups
The resource groups and associated selection rules are configured by a manager which is pluggable. Add an file with the following contents to enable the built-in manager that reads a JSON config file:
Change the value of resource-groups.config-file
to point to a JSON config file, which can be an absolute path, or a path relative to the Presto data directory.
name
(required): name of the group. May be a template (see below).maxQueued
(required): maximum number of queued queries. Once this limit is reached new queries will be rejected.hardConcurrencyLimit
(required): maximum number of running queries.softMemoryLimit
(required): maximum amount of distributed memory this group may use before new queries become queued. May be specified as an absolute value (i.e.1GB
) or as a percentage (i.e.10%
) of the cluster’s memory.softCpuLimit
(optional): maximum amount of CPU time this group may use in a period (seecpuQuotaPeriod
) before a penalty will be applied to the maximum number of running queries.hardCpuLimit
must also be specified.hardCpuLimit
(optional): maximum amount of CPU time this group may use in a period.schedulingPolicy
(optional): specifies how queued queries are selected to run, and how sub-groups become eligible to start their queries. May be one of three values:schedulingWeight
(optional): weight of this sub-group. See above. Defaults to1
.jmxExport
(optional): If true, group statistics are exported to JMX for monitoring. Defaults tofalse
.perQueryLimits
(optional): specifies max resources each query in a resource group may consume before being killed. These limits are not inherited from parent groups. May set three types of limits:subGroups
(optional): list of sub-groups.
user
(optional): regex to match against user name.source
(optional): regex to match against source string.queryType
(optional): string to match against the type of the query submitted:DATA_DEFINITION
: Queries that alter/create/drop the metadata of schemas/tables/views, and that manage prepared statements, privileges, sessions, and transactions.DELETE
:DELETE
queries.DESCRIBE
:DESCRIBE
,DESCRIBE INPUT
,DESCRIBE OUTPUT
, andSHOW
queries.EXPLAIN
:EXPLAIN
queries.INSERT
:INSERT
andCREATE TABLE AS
queries.SELECT
:SELECT
queries.
clientTags
(optional): list of tags. To match, every tag in this list must be in the list of client-provided tags associated with the query.group
(required): the group these queries will run in.
cpuQuotaPeriod
(optional): the period in which cpu quotas are enforced.
Selectors are processed sequentially and the first one that matches will be used.
Client tags can be set as follows:
In the example configuration below, there are several resource groups, some of which are templates. Templates allow administrators to construct resource group trees dynamically. For example, in the pipeline_${USER}
group, will be expanded to the name of the user that submitted the query. ${SOURCE}
is also supported, which will be expanded to the source that submitted the query. You may also use custom named variables in the source
and user
regular expressions.
There are four selectors that define which queries run in which resource group:
Together, these selectors implement the following policy:
- The user “bob” is an admin and can run up to 50 concurrent queries. Queries will be run based on user-provided priority.
For the remaining users:
No more than 100 total queries may run concurrently.
Up to 5 concurrent DDL queries with a source “pipeline” can run. Queries are run in FIFO order.
Non-DDL queries will run under the
global.pipeline
group, with a total concurrency of 45, and a per-user concurrency of 5. Queries are run in FIFO order.All remaining queries are placed into a per-user group under
global.adhoc.other
that behaves similarly.
{
"rootGroups": [
"name": "global",
"softMemoryLimit": "80%",
"hardConcurrencyLimit": 100,
"maxQueued": 1000,
"schedulingPolicy": "weighted",
"jmxExport": true,
"subGroups": [
{
"name": "data_definition",
"softMemoryLimit": "10%",
"hardConcurrencyLimit": 5,
"maxQueued": 100,
"schedulingWeight": 1
},
{
"name": "adhoc",
"softMemoryLimit": "10%",
"hardConcurrencyLimit": 50,
"maxQueued": 1,
"schedulingWeight": 10,
"subGroups": [
{
"name": "other",
"softMemoryLimit": "10%",
"hardConcurrencyLimit": 2,
"maxQueued": 1,
"schedulingWeight": 10,
"schedulingPolicy": "weighted_fair",
"subGroups": [
{
"name": "${USER}",
"softMemoryLimit": "10%",
"hardConcurrencyLimit": 1,
"maxQueued": 100
}
]
},
{
"name": "bi-${tool_name}",
"softMemoryLimit": "10%",
"hardConcurrencyLimit": 10,
"maxQueued": 100,
"schedulingWeight": 10,
"schedulingPolicy": "weighted_fair",
"subGroups": [
"name": "${USER}",
"softMemoryLimit": "10%",
"hardConcurrencyLimit": 3,
"maxQueued": 10
}
]
]
},
{
"name": "pipeline",
"softMemoryLimit": "80%",
"hardConcurrencyLimit": 45,
"maxQueued": 100,
"schedulingWeight": 1,
"jmxExport": true,
"subGroups": [
{
"name": "pipeline_${USER}",
"softMemoryLimit": "50%",
"hardConcurrencyLimit": 5,
"maxQueued": 100
}
]
}
]
},
{
"name": "admin",
"softMemoryLimit": "100%",
"hardConcurrencyLimit": 50,
"maxQueued": 100,
"schedulingPolicy": "query_priority",
"jmxExport": true
}
],
"selectors": [
{
"user": "bob",
"group": "admin"
},
{
"source": ".*pipeline.*",
"queryType": "DATA_DEFINITION",
"group": "global.data_definition"
},
{
"source": ".*pipeline.*",
"group": "global.pipeline.pipeline_${USER}"
},
{
"source": "jdbc#(?<tool_name>.*)",
"clientTags": ["hipri"],
"group": "global.adhoc.bi-${tool_name}.${USER}"
},
{
"group": "global.adhoc.other.${USER}"
}
],