heap_size.asciidoc 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. [[heap-size]]
  2. === Set JVM heap size via jvm.options
  3. By default, Elasticsearch tells the JVM to use a heap with a minimum
  4. and maximum size of 2 GB. When moving to production, it is
  5. important to configure heap size to ensure that Elasticsearch has enough
  6. heap available.
  7. Elasticsearch will assign the entire heap specified in <<sysconfig,es-java-opts>>
  8. via the Xms (minimum heap size) and Xmx (maximum heap size) settings.
  9. The value for these setting depends on the amount of RAM available on
  10. your server. Good rules of thumb are:
  11. * Set the minimum heap size (Xms) and maximum heap size (Xmx) to be
  12. equal to each other.
  13. * The more heap available to Elasticsearch, the more memory it can use for
  14. caching. But note that too much heap can subject you to long garbage
  15. collection pauses.
  16. * Set Xmx to no more than 50% of your physical RAM, to ensure that there
  17. is enough physical RAM left for kernel file system caches.
  18. * Don’t set Xmx to above the cutoff that the JVM uses for compressed
  19. object pointers (compressed oops); the exact cutoff varies but is
  20. near 32 GB. You can verify that you are under the limit by looking
  21. for a line in the logs like the following:
  22. +
  23. heap size [1.9gb], compressed ordinary object pointers [true]
  24. * Even better, try to stay below the threshold for zero-based
  25. compressed oops; the exact cutoff varies but 26 GB is safe on most
  26. systems, but can be as large as 30 GB on some systems. You can verify
  27. that you are under the limit by starting Elasticsearch with the JVM
  28. options `-XX:+UnlockDiagnosticVMOptions -XX:+PrintCompressedOopsMode`
  29. and looking for a line like the following:
  30. +
  31. --
  32. heap address: 0x000000011be00000, size: 27648 MB, zero based Compressed Oops
  33. showing that zero-based compressed oops are enabled instead of
  34. heap address: 0x0000000118400000, size: 28672 MB, Compressed Oops with base: 0x00000001183ff000
  35. --
  36. Here are examples of how to set the heap size via the jvm.options file:
  37. [source,txt]
  38. ------------------
  39. -Xms2g <1>
  40. -Xmx2g <2>
  41. ------------------
  42. <1> Set the minimum heap size to 2g.
  43. <2> Set the maximum heap size to 2g.
  44. It is also possible to set the heap size via an environment variable.
  45. This can be done by commenting out the `Xms` and `Xmx` settings
  46. in the jvm.options file and setting these values via `ES_JAVA_OPTS`:
  47. [source,sh]
  48. ------------------
  49. ES_JAVA_OPTS="-Xms2g -Xmx2g" ./bin/elasticsearch <1>
  50. ES_JAVA_OPTS="-Xms4000m -Xmx4000m" ./bin/elasticsearch <2>
  51. ------------------
  52. <1> Set the minimum and maximum heap size to 2 GB.
  53. <2> Set the minimum and maximum heap size to 4000 MB.
  54. NOTE: Configuring the heap for the <<windows-service,Windows service>>
  55. is different than the above. The values initiallly populated for the
  56. Windows service can be configured as above but are different after the
  57. service has been installed. Consult the
  58. <<windows-service,Windows service documentation>> for additional
  59. details.