Updated on 2023-06-20 GMT+08:00

CPU Flow Control

Context

CPU flow control can be implemented based on the CPU usage of a node.

You can configure the CPU usage threshold of a node to prevent the node from breaking down due to heavy traffic. You can determine the CPU usage threshold based on the traffic threshold. If the CPU usage of a node exceeds the configured threshold, CPU flow control discards excess node requests to protect the cluster. Traffic within the node or passing through Elasticsearch monitoring APIs are not affected.

The following table describes CPU flow control parameters.

Table 1 CPU flow control parameters

Parameter

Type

Description

flowcontrol.cpu.enabled

Boolean

Whether to enable CPU flow control. If this function is enabled, the node access performance may be affected.

Value: true or false

Default value: false

flowcontrol.cpu.percent_limit

Integer

Maximum CPU usage of a node.

Value range: 0–100

Default value: 90

flowcontrol.cpu.allow_path

List

Path whitelist for CPU flow control. The paths specified in the allow_path whitelist are not under CPU flow control.

The default value is null.

A path can contain up to 32 characters. A maximum of 10 request paths can be configured. Wildcard characters are supported. For example, if this parameter is set to auto_*/_search, all the search requests of the indexes prefixed with auto_ are not under the flow control.

flowcontrol.cpu.*.filter_path

String

Paths under CPU flow control.

Maximum length: 32 characters

Example:

"flowcontrol.cpu.search.filter_path": "/index/_search",

"flowcontrol.cpu.search.limit": 60,

The default value is **, indicating all paths. If limit is configured and filter_path is not, it indicates that all the paths, except those in the whitelist, are under control. The whitelist takes precedence over the single-path rule. If a path is specified in both allow_path and filter_path, the requests from the path will be allowed.

For example, if both filter_path and allow_path both set to abc/_search, then abc/_search will not be under flow control.

flowcontrol.cpu.*.limit

Integer

CPU threshold of request paths. If the CPU usage exceeds the threshold, flow control will be triggered.

Value range: 0–100

Default value: 90

Procedure

  1. Log in to the CSS management console.
  2. Choose Clusters in the navigation pane. On the Clusters page, locate the target cluster and click Access Kibana in the Operation column.
  3. In the navigation pane on the left, choose Dev Tools and run commands to enable or disable memory flow control.
    • Enabling CPU flow control
      PUT /_cluster/settings
      {
        "persistent": {
          "flowcontrol.cpu.enabled": true,
          "flowcontrol.cpu.percent_limit": 80,
          "flowcontrol.cpu.allow_path": ["index/_search"]
        }
      }
    • Disabling CPU flow control
      PUT /_cluster/settings
      {
        "persistent": {
          "flowcontrol.cpu.enabled": false
        }
      }