advanced-configuration.asciidoc 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. [[advanced-configuration]]
  2. === Advanced configuration settings
  3. The settings below are considered advanced and for expert users only. In
  4. most cases the {es}-provided default settings should be used. Take caution
  5. when modifying these settings as this could result in undesired behavior or
  6. reduced system performance.
  7. [[setting-jvm-heap-size]]
  8. ==== Setting JVM heap size
  9. If you need to override the default <<heap-size-settings,heap size settings>>,
  10. follow the best practices below.
  11. {es} assigns the entire heap specified in
  12. <<jvm-options,jvm.options>> via the `Xms` (minimum heap size) and `Xmx` (maximum
  13. heap size) settings. These two settings must be equal to each other.
  14. The value for these settings depends on the amount of RAM available on your
  15. server:
  16. * Set `Xmx` and `Xms` to no more than 50% of your total system memory. {es} requires
  17. memory for purposes other than the JVM heap and it is important to leave
  18. space for this. For instance, {es} uses off-heap buffers for efficient
  19. network communication, relies on the operating system's filesystem cache for
  20. efficient access to files, and the JVM itself requires some memory too. It is
  21. normal to observe the {es} process using more memory than the limit
  22. configured with the `Xmx` setting.
  23. * Set `Xmx` and `Xms` to no more than the threshold that the JVM uses for
  24. compressed object pointers (compressed oops). The exact threshold varies but
  25. is near 32 GB. You can verify that you are under the threshold by looking for a line in the logs like the following:
  26. +
  27. [source,txt]
  28. ----
  29. heap size [1.9gb], compressed ordinary object pointers [true]
  30. ----
  31. * Set `Xmx` and `Xms` to no more than the threshold for zero-based
  32. compressed oops. The exact threshold varies but 26GB is safe on most
  33. systems and can be as large as 30GB on some systems. You can verify that
  34. you are under this threshold by starting {es} with the JVM options
  35. `-XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode` and looking for
  36. a line like the following:
  37. +
  38. [source,txt]
  39. ----
  40. heap address: 0x000000011be00000, size: 27648 MB, zero based Compressed Oops
  41. ----
  42. +
  43. This line shows that zero-based compressed oops are enabled. If zero-based
  44. compressed oops are not enabled, you'll see a line like the following instead:
  45. +
  46. [source,txt]
  47. ----
  48. heap address: 0x0000000118400000, size: 28672 MB, Compressed Oops with base: 0x00000001183ff000
  49. ----
  50. The more heap available to {es}, the more memory it can use for its internal
  51. caches. This leaves less memory for the operating system to use
  52. for the filesystem cache. Larger heaps can also cause longer garbage
  53. collection pauses.
  54. Here is an example of how to set the heap size via a `jvm.options.d/` file:
  55. [source,txt]
  56. ------------------
  57. -Xms2g <1>
  58. -Xmx2g <2>
  59. ------------------
  60. <1> Set the minimum heap size to 2g.
  61. <2> Set the maximum heap size to 2g.
  62. In production, we recommend using `jvm.options.d` to configure heap sizes.
  63. For testing, you can also set the heap sizes using the `ES_JAVA_OPTS`
  64. environment variable. The `ES_JAVA_OPTS` variable overrides all other JVM
  65. options. We do not recommend using `ES_JAVA_OPTS` in production.
  66. [source,sh]
  67. ------------------
  68. ES_JAVA_OPTS="-Xms2g -Xmx2g" ./bin/elasticsearch <1>
  69. ES_JAVA_OPTS="-Xms4000m -Xmx4000m" ./bin/elasticsearch <2>
  70. ------------------
  71. <1> Set the minimum and maximum heap size to 2 GB.
  72. <2> Set the minimum and maximum heap size to 4000 MB.
  73. NOTE: Configuring the heap for the <<windows-service,Windows service>> is
  74. different than the above. The values initially populated for the Windows
  75. service can be configured as above but are different after the service has been
  76. installed. See <<windows-service>>.