high-jvm-memory-pressure.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. [[high-jvm-memory-pressure]]
  2. === High JVM memory pressure
  3. High JVM memory usage can degrade cluster performance and trigger
  4. <<circuit-breaker-errors,circuit breaker errors>>. To prevent this, we recommend
  5. taking steps to reduce memory pressure if a node's JVM memory usage consistently
  6. exceeds 85%.
  7. ****
  8. If you're using Elastic Cloud Hosted, then you can use AutoOps to monitor your cluster. AutoOps significantly simplifies cluster management with performance recommendations, resource utilization visibility, real-time issue detection and resolution paths. For more information, refer to https://www.elastic.co/guide/en/cloud/current/ec-autoops.html[Monitor with AutoOps].
  9. ****
  10. [discrete]
  11. [[diagnose-high-jvm-memory-pressure]]
  12. ==== Diagnose high JVM memory pressure
  13. **Check JVM memory pressure**
  14. include::{es-ref-dir}/tab-widgets/jvm-memory-pressure-widget.asciidoc[]
  15. **Check garbage collection logs**
  16. As memory usage increases, garbage collection becomes more frequent and takes
  17. longer. You can track the frequency and length of garbage collection events in
  18. <<logging,`elasticsearch.log`>>. For example, the following event states {es}
  19. spent more than 50% (21 seconds) of the last 40 seconds performing garbage
  20. collection.
  21. [source,log]
  22. ----
  23. [timestamp_short_interval_from_last][INFO ][o.e.m.j.JvmGcMonitorService] [node_id] [gc][number] overhead, spent [21s] collecting in the last [40s]
  24. ----
  25. **Capture a JVM heap dump**
  26. To determine the exact reason for the high JVM memory pressure, capture a heap
  27. dump of the JVM while its memory usage is high, and also capture the
  28. <<gc-logging,garbage collector logs>> covering the same time period.
  29. [discrete]
  30. [[reduce-jvm-memory-pressure]]
  31. ==== Reduce JVM memory pressure
  32. This section contains some common suggestions for reducing JVM memory pressure.
  33. **Reduce your shard count**
  34. Every shard uses memory. In most cases, a small set of large shards uses fewer
  35. resources than many small shards. For tips on reducing your shard count, see
  36. <<size-your-shards>>.
  37. [[avoid-expensive-searches]]
  38. **Avoid expensive searches**
  39. Expensive searches can use large amounts of memory. To better track expensive
  40. searches on your cluster, enable <<index-modules-slowlog,slow logs>>.
  41. Expensive searches may have a large <<paginate-search-results,`size` argument>>,
  42. use aggregations with a large number of buckets, or include
  43. <<query-dsl-allow-expensive-queries,expensive queries>>. To prevent expensive
  44. searches, consider the following setting changes:
  45. * Lower the `size` limit using the
  46. <<index-max-result-window,`index.max_result_window`>> index setting.
  47. * Decrease the maximum number of allowed aggregation buckets using the
  48. <<search-settings-max-buckets,search.max_buckets>> cluster setting.
  49. * Disable expensive queries using the
  50. <<query-dsl-allow-expensive-queries,`search.allow_expensive_queries`>> cluster
  51. setting.
  52. * Set a default search timeout using the <<search-timeout,`search.default_search_timeout`>> cluster setting.
  53. [source,console]
  54. ----
  55. PUT _settings
  56. {
  57. "index.max_result_window": 5000
  58. }
  59. PUT _cluster/settings
  60. {
  61. "persistent": {
  62. "search.max_buckets": 20000,
  63. "search.allow_expensive_queries": false
  64. }
  65. }
  66. ----
  67. // TEST[s/^/PUT my-index\n/]
  68. **Prevent mapping explosions**
  69. Defining too many fields or nesting fields too deeply can lead to
  70. <<mapping-limit-settings,mapping explosions>> that use large amounts of memory.
  71. To prevent mapping explosions, use the <<mapping-settings-limit,mapping limit
  72. settings>> to limit the number of field mappings.
  73. **Spread out bulk requests**
  74. While more efficient than individual requests, large <<docs-bulk,bulk indexing>>
  75. or <<search-multi-search,multi-search>> requests can still create high JVM
  76. memory pressure. If possible, submit smaller requests and allow more time
  77. between them.
  78. **Upgrade node memory**
  79. Heavy indexing and search loads can cause high JVM memory pressure. To better
  80. handle heavy workloads, upgrade your nodes to increase their memory capacity.