Elasticsearch provides a circuit breaker, which will terminate requests or return the error code 429 if the memory usage exceeds its threshold. However, the circuit breaker rejects a request only after the node reads the entire request, which occupies heap memory. To prevent a request from being fully received by a node before the request is rejected, you can control the client traffic based on the real-time status of the node heap memory.
The following table describes memory flow control parameters.
Parameter |
Type |
Description |
---|---|---|
flowcontrol.memory.enabled |
Boolean |
Whether to enable memory flow control. After this function is enabled, the memory usage is continuously monitored. The value can be:
|
flowcontrol.memory.heap_limit |
String |
Maximum global heap memory usage of a node. If the value of this parameter is exceeded, traffic backpressure is performed. Value range: 10%–100% Default value: 90% |
flowcontrol.holding.in_flight_factor |
Float |
Backpressure release factor. The principle is similar to that of the circuit breaker parameter network.breaker.inflight_requests.overhead. When the memory usage reaches the limit, a larger value indicates stronger backpressure. The write traffic will be limited. Value range: ≥ 0.5 Default value: 1.0 |
flowcontrol.holding.max |
TimeValue |
Maximum delay of each request. If the delay exceeds the value of this parameter, you can disconnect the request backpressure or disconnect the request link. For details, see the configuration of flowcontrol.holding.max_strategy. Value range: ≥ 15s Default value: 60s |
flowcontrol.holding.max_strategy |
String |
Policy after the maximum delay time is exceeded. The value can be:
|
flowcontrol.memory.once_free_max |
String |
Maximum memory that can be opened at a time for a suspended request queue. This parameter is used to prevent a cluster from being entirely suspended due to temporary low memory under high pressure. Value range: 1 to 50 Default value: 10% |
flowcontrol.memory.nudges_gc |
Boolean |
Whether to trigger garbage collection to ensure write stability when the write pressure is too high. (The backpressure connection pool is checked every second. The write pressure is regarded high if all the existing connections are blocked and new write requests cannot be released.) The value can be:
|
PUT /_cluster/settings { "persistent": { "flowcontrol.memory.enabled": true, "flowcontrol.memory.heap_limit": "80%" } }
PUT /_cluster/settings { "persistent": { "flowcontrol.memory.enabled": false } }