Skip to content

Commit

Permalink
[docs]add concurrency control en (#1653)
Browse files Browse the repository at this point in the history
## Versions 

- [x] dev
- [ ] 3.0
- [ ] 2.1
- [ ] 2.0

## Languages

- [ ] Chinese
- [x] English

## Docs Checklist

- [ ] Checked by AI
- [ ] Test Cases Built
  • Loading branch information
wangbo authored Dec 27, 2024
1 parent 9528f0e commit bf7e729
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
{
"title": "Concurrency Control and Queuing",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

Concurrency control and queuing is a resource management mechanism. When multiple queries simultaneously request resources and reach the system's concurrency limit, Doris will manage the queries based on predefined strategies and restrictions, ensuring the system can still operate smoothly under high load and avoid issues like OOM (Out of Memory) or system freezes.

Doris's concurrency control and queuing mechanism is primarily implemented through workload groups. A workload group defines the resource usage limits for queries, including maximum concurrency, queue length, and timeout parameters. By properly configuring these parameters, the goal of resource management can be achieved.

## Basic usage

```
create workload group if not exists queue_group
properties (
"max_concurrency" = "10",
"max_queue_size" = "20",
"queue_timeout" = "3000"
);
```

**Parameter description**


| Property | Data type | Default value | Value range | Description |
|-----------------|-----------|---------------|-----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| max_concurrency | Integer | 2147483647 | [0, 2147483647] | Optional, the maximum number of concurrent queries. The default value is the maximum integer value, meaning there is no limit on concurrency. When the number of running queries reaches the maximum concurrency, new queries will enter the queuing process. |
| max_queue_size | Integer | 0 | [0, 2147483647] | Optional, the length of the query queue. When the queue is full, new queries will be rejected. The default value is 0, meaning no queuing. |
| queue_timeout | Integer | 0 | [0, 2147483647] | Optional, the maximum wait time for a query in the queue, in milliseconds. If the query exceeds this time in the queue, an exception will be thrown to the client. The default value is 0, meaning no queuing, and queries will immediately fail upon entering the queue. |


If there is currently 1 FE in the cluster, the meaning of this configuration is as follows: The maximum number of concurrent queries in the cluster is limited to 10. When the maximum concurrency is reached, new queries will enter the queue, with the queue length limited to 20. The maximum wait time for a query in the queue is 3 seconds, and queries that exceed 3 seconds in the queue will return a failure directly to the client.

:::tip
The current queuing design does not take into account the number of FEs. The queuing parameters only take effect at the single FE level. For example:

In a Doris cluster, if a workload group is configured with max_concurrency = 1,
If there is 1 FE in the cluster, the workload group will allow only one SQL query to run at a time in the cluster;
If there are 3 FEs in the cluster, the maximum number of SQL queries in the cluster could be 3.
:::

## Check the queue status

**grammar**

```
show workload groups
```

**example**

```
mysql [(none)]>show workload groups\G;
*************************** 1. row ***************************
Id: 1
Name: normal
cpu_share: 20
memory_limit: 50%
enable_memory_overcommit: true
max_concurrency: 2147483647
max_queue_size: 0
queue_timeout: 0
cpu_hard_limit: 1%
scan_thread_num: 16
max_remote_scan_thread_num: -1
min_remote_scan_thread_num: -1
memory_low_watermark: 50%
memory_high_watermark: 80%
tag:
read_bytes_per_second: -1
remote_read_bytes_per_second: -1
running_query_num: 0
waiting_query_num: 0
```

```running_query_num```Represents the number of queries currently running, ```waiting_query_num```Represents the number of queries in the queue.

## Bypass the queuing

In some operational scenarios, the administrator account needs to bypass the queuing logic to execute SQL for system management tasks. This can be done by setting session variables to bypass the queuing:

```
set bypass_workload_group = true;
```
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ properties (
| 属性名称 | 数据类型 | 默认值 | 取值范围 | 说明 |
|------------------------------|---------|-----|-----|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| max_concurrency | 整型 | 2147483647 | [0, 2147483647] | 可选,最大查询并发数,默认值为整型最大值,也就是不做并发的限制。运行中的查询数量达到最大并发时,新来的查询会进入排队的逻辑。 |
| max_queue_size | 整型 | 0 | [0, 2147483647] | 可选,查询排队队列的长度,当排队队列已满时,新来的查询会被拒绝。默认值为 0,含义是不排队。当排队队列已满时,新来的查询会直接失败。 |
| max_queue_size | 整型 | 0 | [0, 2147483647] | 可选,查询排队队列的长度,当排队队列已满时,新来的查询会被拒绝。默认值为 0,含义是不排队。 |
| queue_timeout | 整型 | 0 | [0, 2147483647] | 可选,查询在排队队列中的最大等待时间,单位为毫秒。如果查询在队列中的排队时间超过这个值,那么就会直接抛出异常给客户端。默认值为 0,含义是不排队,查询进入队列后立即返回失败。 |

如果集群中目前有1台FE,那么这个配置的含义为,集群中同时运行的查询数最大不超过10个,当最大并发已满时,新来的查询会排队,队列的长度不超过20。查询在队列中排队的时间最长为3s,排队超过3s的查询会直接返回失败给客户端。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ properties (
| 属性名称 | 数据类型 | 默认值 | 取值范围 | 说明 |
|------------------------------|---------|-----|-----|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| max_concurrency | 整型 | 2147483647 | [0, 2147483647] | 可选,最大查询并发数,默认值为整型最大值,也就是不做并发的限制。运行中的查询数量达到最大并发时,新来的查询会进入排队的逻辑。 |
| max_queue_size | 整型 | 0 | [0, 2147483647] | 可选,查询排队队列的长度,当排队队列已满时,新来的查询会被拒绝。默认值为 0,含义是不排队。当排队队列已满时,新来的查询会直接失败。 |
| max_queue_size | 整型 | 0 | [0, 2147483647] | 可选,查询排队队列的长度,当排队队列已满时,新来的查询会被拒绝。默认值为 0,含义是不排队。 |
| queue_timeout | 整型 | 0 | [0, 2147483647] | 可选,查询在排队队列中的最大等待时间,单位为毫秒。如果查询在队列中的排队时间超过这个值,那么就会直接抛出异常给客户端。默认值为 0,含义是不排队,查询进入队列后立即返回失败。 |

如果集群中目前有1台FE,那么这个配置的含义为,集群中同时运行的查询数最大不超过10个,当最大并发已满时,新来的查询会排队,队列的长度不超过20。查询在队列中排队的时间最长为3s,排队超过3s的查询会直接返回失败给客户端。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ properties (
| 属性名称 | 数据类型 | 默认值 | 取值范围 | 说明 |
|------------------------------|---------|-----|-----|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| max_concurrency | 整型 | 2147483647 | [0, 2147483647] | 可选,最大查询并发数,默认值为整型最大值,也就是不做并发的限制。运行中的查询数量达到最大并发时,新来的查询会进入排队的逻辑。 |
| max_queue_size | 整型 | 0 | [0, 2147483647] | 可选,查询排队队列的长度,当排队队列已满时,新来的查询会被拒绝。默认值为 0,含义是不排队。当排队队列已满时,新来的查询会直接失败。 |
| max_queue_size | 整型 | 0 | [0, 2147483647] | 可选,查询排队队列的长度,当排队队列已满时,新来的查询会被拒绝。默认值为 0,含义是不排队。 |
| queue_timeout | 整型 | 0 | [0, 2147483647] | 可选,查询在排队队列中的最大等待时间,单位为毫秒。如果查询在队列中的排队时间超过这个值,那么就会直接抛出异常给客户端。默认值为 0,含义是不排队,查询进入队列后立即返回失败。 |

如果集群中目前有1台FE,那么这个配置的含义为,集群中同时运行的查询数最大不超过10个,当最大并发已满时,新来的查询会排队,队列的长度不超过20。查询在队列中排队的时间最长为3s,排队超过3s的查询会直接返回失败给客户端。
Expand Down

0 comments on commit bf7e729

Please sign in to comment.