# Elasticsearch异常：分片请求缓存逐出触发内存压力，当前堆使用率 [85%]

- **ID:** `elasticsearch/shard-request-cache-eviction-memory-pressure`
- **领域:** elasticsearch
- **类别:** resource_error
- **错误码:** `ES_SHARD_CACHE_EVICTION_MEM`
- **验证级别:** ai_generated
- **修复率:** 83%

## 根因

在高查询负载下，分片请求缓存增长过大，导致频繁逐出，增加堆压力并降低性能。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.17.0 | active | — | — |
| 8.11.0 | active | — | — |
| 8.12.0 | active | — | — |

## 解决方案

1. ```
   Reduce cache size by setting `indices.requests.cache.size: 1%` in `elasticsearch.yml` to limit heap usage.
   ```
2. ```
   Use explicit query caching with `?request_cache=true` only for queries that benefit from it, and set `index.requests.cache.enable: false` on indices with high write volume.
   ```
3. ```
   Monitor cache eviction rates via `GET _nodes/stats/indices/request_cache` and optimize queries to reduce cache churn.
   ```

## 无效尝试

- **** — Larger heap delays evictions but doesn't solve the root cause of excessive caching; cache can grow unbounded and cause GC issues. (70% 失败率)
- **** — Disabling cache increases query latency for repeated queries, especially in dashboards or reporting scenarios. (65% 失败率)
