The aliyun-qos plug-in is a cluster-level read and write throttling plug-in developed by the Alibaba Cloud Elasticsearch team. When upstream services cannot control traffic, you can use the aliyun-qos plug-in to throttle specific indexes based on business priority. This helps keep traffic manageable and ensures your Elasticsearch cluster's stability.
Precautions
The
aliyun-qosplug-in is pre-installed and cannot be uninstalled. Its throttling feature is disabled by default. The plug-in is designed to protect cluster stability, not to precisely measure read and write traffic.Plug-in version: Before using the
aliyun-qosplug-in, ensure it is updated to the latest version. Log on to the Kibana console and runGET /_cat/plugins?vto check the plug-in version.The plug-in version is in the format
<cluster version>_ali<internal version number>, for example,7.10.0_ali1.6.0.2or8.17.0_ali2.2.0.4.1. If the plug-in version is not the latest, refer to the following methods to upgrade it:For a V7.10 cluster: In the console, upgrade the kernel to version 1.6.0. For more information, see Upgrade cluster versions.
For other cluster versions: Submit a ticket to Alibaba Cloud Support to upgrade the plug-in. After the upgrade, you must manually restart the Elasticsearch cluster for the new version to take effect.
If the plug-in version is earlier than rc4, an
unsupported_operation_exceptionerror occurs. Thealiyun-qosplug-in can be upgraded only on clusters running V6.7.0 or later. You must first upgrade clusters running earlier versions to V6.7.0 or later.
Evaluate thresholds
The aliyun-qos plug-in performs throttling at the cluster level. To minimize performance overhead, it does not precisely measure read and write traffic on all nodes, so the actual traffic might differ from the measured traffic. Before you use the plug-in, evaluate the throttling threshold based on the following rules:
Query requests
Throttling threshold for query requests = End-to-end QPS (queries per second) from the client to Elasticsearch
End-to-end QPS refers only to the number of query requests that reach the client nodes per second.
Write requests
The rule for calculating the write request throttling threshold is similar to that for query requests, but requires adjustment for the number of replica shards.
For example, consider a cluster with two data nodes and one index. The index has one primary shard and one replica shard. Each write operation sends 10 MB of data. Because a replica shard exists, 10 MB of data is written to each data node. Additionally, internal X-Pack tasks such as Monitor, Audit, and Watcher also consume write throughput. Reserve capacity for this traffic when setting the threshold.
Enable throttling
The throttling feature of the aliyun-qos plug-in is disabled by default. You must enable it before use. The command to enable the feature varies by plug-in version.
Latest V7.10 version | Other versions |
| |
Disable throttling
You can disable the throttling feature by setting the limiter parameter to false or null. The command varies by version.
Method | Latest V7.10 version | Other versions |
Set the limiter parameter to | | |
Set the limiter parameter to | | |
Configure a limiter (latest V7.10 version)
The following limiter configurations apply only to the aliyun-qos plug-in for V7.10 clusters.
A limiter configuration consists of two parts: limiters and tags. The tags section defines the scope of resource limits, while the limiters section defines the specific throttling type and threshold. Limiters can be standard or default. You can create a default limiter by setting a tag value to **. For example, you can set a default throughput for each shard or a default QPS for each application. When a request exceeds a limit, Elasticsearch rejects subsequent requests.
PUT /_qos/limiter/<limiterName>
{
"limiters": {
${action}.${limiter_type}:${threshold}
},
"tags": {
${tagName}:${tagValue}
},
"priority":0,
"params":{
"watchMode":true
}
}Parameter | Description | Value |
action | The action to be throttled. This is used to limit different types of requests. |
|
limiter_type | The throttling type. Three categories are supported: rate, concurrency, and per-request limits. |
|
threshold | The throttling threshold. | An integer greater than or equal to -1. Some types support strings with units. For more information, see the description of |
tagName | The tag name. |
|
tagValue | The tag value. | A string or an array of strings. If an array is used, the tag matches any value in the array. Exact match, prefix match with a wildcard, and all values are supported. Examples:
|
priority | The priority of the limiter. | An integer. Default value: 0. A higher value indicates a higher priority. When a request matches multiple default limiters, only the one with the highest priority takes effect. |
params | Advanced parameters. |
|
Limiter configuration examples
Set QPS throttling for queries
You can limit the query QPS on a client node by setting a threshold for an index. When the number of query requests per second exceeds the threshold, Elasticsearch rejects subsequent requests.
The values for index and index_patterns can be full index names or names with a wildcard. The command varies by version.
Actions | Latest V7.10 version | Other versions |
Set query QPS throttling for a single index | | |
Set query QPS throttling for indexes with a specific name prefix | | |
Set query QPS throttling for each index individually | | Not supported. |
Set a total query QPS limit for all indexes |
| |
You can define multiple rules. Throttling is triggered if a request matches any rule.
When the query QPS exceeds the configured limit, the system returns an error message. The error message varies by version:
Latest V7.10 version
{ "error": { "root_cause": [ { "type": "status_exception", "reason": "search blocked, limited by [<limiterName>][search.qps](<limiterId>) threshold:[x]" } ], "type": "status_exception", "reason": "search blocked, limited by [<limiterName>][search.qps](<limiterId>) threshold:[x]" }, "status": 429 }Other versions
{ "error": { "root_cause": [ { "type": "rate_limited_exception", "reason": "request indices:data/read/search rejected, limited by [l1:t*:1.0]" } ], "type": "rate_limited_exception", "reason": "request indices:data/read/search rejected, limited by [l1:t*:1.0]" }, "status": 429 }
Set TPS throttling for writes
You can limit the number of write requests per second that a client node receives by setting a TPS (transactions per second) threshold. When the number of write requests per second exceeds the threshold, Elasticsearch rejects subsequent requests.
The values for index and index_patterns can be full index names or names with a wildcard. The command varies by version.
Latest V7.10 version | Other versions |
| Not supported |
Set throughput throttling for Bulk requests
You can limit the write throughput for Bulk API requests on a client node by setting a limit in bytes per second. When the write throughput exceeds this limit, Elasticsearch rejects subsequent requests.
The values for index and index_patterns can be full index names or names with a wildcard. The command varies by version.
Latest V7.10 version | Other versions |
| |
You can define multiple rules. Throttling is triggered if a request matches any rule.
Set request size throttling for Bulk requests
You can limit the size of a single Bulk API request on a client node. If a request exceeds this size limit, Elasticsearch rejects it.
The values for index and index_patterns can be full index names or names with a wildcard. The command varies by version.
Latest V7.10 version | Other versions |
| |
You can define multiple rules. Throttling is triggered if a request matches any rule.
When the size of a single write request exceeds the configured limit, the system returns an error message. The error message varies by version:
Latest V7.10 version
{ "error" : { "root_cause" : [ { "type" : "status_exception", "reason" : "write_size blocked, limited by [<limiterName>][write.max_size_per_request](<limiterId>) threshold:[x] try acquire [x]" } ], "type" : "status_exception", "reason" : "write_size blocked, limited by [<limiterName>][write.max_size_per_request](<limiterId>) threshold:[x] try acquire [x]" }, "status" : 400 }Other versions
{ "error": { "root_cause": [ { "type": "rate_limited_exception", "reason": "request indices:data/write/bulk rejected, limited by [b2:ByteSizePreSeconds:992.0]" } ], "type": "rate_limited_exception", "reason": "request indices:data/write/bulk rejected, limited by [b2:ByteSizePreSeconds:992.0]" }, "status": 413 }
Set concurrency throttling for shard queries
You can reduce the load on your cluster by setting the number of concurrent shard queries. The values for index and index_patterns can be full index names or names with a wildcard. The command varies by version.
Latest V7.10 version | Other versions |
| Not supported |
You can define multiple rules. Throttling is triggered if a request matches any rule.
Set multiple limiter configurations
You can define multiple limits within a single limiter configuration. The values for index and index_patterns can be full index names or names with a wildcard. The command varies by version.
Latest V7.10 version | Other versions |
| Not supported |
You can define multiple rules. Throttling is triggered if a request matches any rule.
Get limiter configurations
The command to get limiter configurations varies by version.
Actions | Latest V7.10 version | Other versions |
Get all limiter configurations | | |
Get a single specified limiter configuration | | |
Get multiple specified limiter configurations. Separate multiple limiter names with commas (,). Wildcards are not supported. | | |
Delete limiter configurations
The command to delete limiter configurations varies by version.
Actions | Latest V7.10 version | Other versions |
Delete a single specified limiter configuration | | |
Delete multiple specified limiter configurations. Separate multiple limiter names with commas (,). Wildcards are not supported. | | |
FAQ
Q: How do I obtain monitoring metrics related to throttling?
A: You can use the following APIs:
Get current metric data
Get current data for all metrics
GET /_qos/limiter/nodes/statsGet current metric data for a specific node
GET /_qos/limiter/nodes/{nodeId}/statsGet current metric data for a specific node and limiter
GET /_qos/limiter/nodes/{nodeId}/stats/{limiterIds}
Get historical metric data
Get historical data for all metrics
GET /_qos/limiter/metricGet historical metric data for a specific limiter
GET /_qos/limiter/metric/{limiterId}
Notes on plug-in upgrades
When you upgrade the aliyun-qos plug-in to the latest version, take note of the following:
Due to differences in the implementation mechanism between old and new versions, the throttling feature may be temporarily unavailable during the upgrade process. It automatically restores after the plug-in on the master node is upgraded.
During the data conversion process, some limiters may fail to convert from the old format. If a conversion fails, run the following command to retry. If the command returns an error, you can run it multiple times until
hasErrorisfalse.POST /_qos/limiter/ops/upgradeIf the preceding command returns an error message (such as
unknown action), this indicates that the cluster does not have a legacy throttler. You can ignore the message.