frozen-indices.asciidoc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[frozen-indices]]
  4. = Frozen indices
  5. [partintro]
  6. --
  7. {es} indices keep some data structures in memory to allow you to search them
  8. efficiently and to index into them. If you have a lot of indices then the
  9. memory required for these data structures can add up to a significant amount.
  10. For indices that are searched frequently it is better to keep these structures
  11. in memory because it takes time to rebuild them. However, you might access some
  12. of your indices so rarely that you would prefer to release the corresponding
  13. memory and rebuild these data structures on each search.
  14. For example, if you are using time-based indices to store log messages or time
  15. series data then it is likely that older indices are searched much less often
  16. than the more recent ones. Older indices also receive no indexing requests.
  17. Furthermore, it is usually the case that searches of older indices are for
  18. performing longer-term analyses for which a slower response is acceptable.
  19. If you have such indices then they are good candidates for becoming _frozen
  20. indices_. {es} builds the transient data structures of each shard of a frozen
  21. index each time that shard is searched, and discards these data structures as
  22. soon as the search is complete. Because {es} does not maintain these transient
  23. data structures in memory, frozen indices consume much less heap than normal
  24. indices. This allows for a much higher disk-to-heap ratio than would otherwise
  25. be possible.
  26. You can freeze the index using the <<freeze-index-api, Freeze Index API>>.
  27. Searches performed on frozen indices use the small, dedicated,
  28. <<search-throttled,`search_throttled` threadpool>> to control the number of
  29. concurrent searches that hit frozen shards on each node. This limits the amount
  30. of extra memory required for the transient data structures corresponding to
  31. frozen shards, which consequently protects nodes against excessive memory
  32. consumption.
  33. Frozen indices are read-only: you cannot index into them.
  34. Searches on frozen indices are expected to execute slowly. Frozen indices are
  35. not intended for high search load. It is possible that a search of a frozen
  36. index may take seconds or minutes to complete, even if the same searches
  37. completed in milliseconds when the indices were not frozen.
  38. To make a frozen index writable again, use the <<unfreeze-index-api, Unfreeze Index API>>.
  39. --
  40. [role="xpack"]
  41. [testenv="basic"]
  42. [[best_practices]]
  43. == Best practices
  44. Since frozen indices provide a much higher disk to heap ratio at the expense of search latency, it is advisable to allocate frozen indices to
  45. dedicated nodes to prevent searches on frozen indices influencing traffic on low latency nodes. There is significant overhead in loading
  46. data structures on demand which can cause page faults and garbage collections, which further slow down query execution.
  47. Since indices that are eligible for freezing are unlikely to change in the future, disk space can be optimized as described in <<tune-for-disk-usage>>.
  48. It's highly recommended to <<indices-forcemerge,`_forcemerge`>> your indices prior to freezing to ensure that each shard has only a single
  49. segment on disk. This not only provides much better compression but also simplifies the data structures needed to service aggregation
  50. or sorted search requests.
  51. [source,console]
  52. --------------------------------------------------
  53. POST /twitter/_forcemerge?max_num_segments=1
  54. --------------------------------------------------
  55. // TEST[setup:twitter]
  56. [role="xpack"]
  57. [testenv="basic"]
  58. [[searching_a_frozen_index]]
  59. == Searching a frozen index
  60. Frozen indices are throttled in order to limit memory consumptions per node. The number of concurrently loaded frozen indices per node is
  61. limited by the number of threads in the <<search-throttled,search_throttled>> threadpool, which is `1` by default.
  62. Search requests will not be executed against frozen indices by default, even if a frozen index is named explicitly. This is
  63. to prevent accidental slowdowns by targeting a frozen index by mistake. To include frozen indices a search request must be executed with
  64. the query parameter `ignore_throttled=false`.
  65. [source,console]
  66. --------------------------------------------------
  67. GET /twitter/_search?q=user:kimchy&ignore_throttled=false
  68. --------------------------------------------------
  69. // TEST[setup:twitter]
  70. [role="xpack"]
  71. [testenv="basic"]
  72. [[monitoring_frozen_indices]]
  73. == Monitoring frozen indices
  74. Frozen indices are ordinary indices that use search throttling and a memory efficient shard implementation. For API's like the
  75. <<cat-indices>> frozen indices may identified by an index's `search.throttled` property (`sth`).
  76. [source,console]
  77. --------------------------------------------------
  78. GET /_cat/indices/twitter?v&h=i,sth
  79. --------------------------------------------------
  80. // TEST[s/^/PUT twitter\nPOST twitter\/_freeze\n/]
  81. The response looks like:
  82. [source,txt]
  83. --------------------------------------------------
  84. i sth
  85. twitter true
  86. --------------------------------------------------
  87. // TESTRESPONSE[non_json]