transforms-at-scale.asciidoc 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. [role="xpack"]
  2. [[transform-scale]]
  3. = Working with {transforms} at scale
  4. ++++
  5. <titleabbrev>{transforms-cap} at scale</titleabbrev>
  6. ++++
  7. {transforms-cap} convert existing {es} indices into summarized indices, which
  8. provide opportunities for new insights and analytics. The search and index
  9. operations performed by {transforms} use standard {es} features so similar
  10. considerations for working with {es} at scale are often applicable to
  11. {transforms}. If you experience performance issues, start by identifying the
  12. bottleneck areas (search, indexing, processing, or storage) then review the
  13. relevant considerations in this guide to improve performance. It also helps to
  14. understand how {transforms} work as different considerations apply depending on
  15. whether or not your transform is running in continuous mode or in batch.
  16. In this guide, you’ll learn how to:
  17. * Understand the impact of configuration options on the performance of
  18. {transforms}.
  19. **Prerequisites:**
  20. These guildelines assume you have a {transform} you want to tune, and you’re
  21. already familiar with:
  22. * <<transform-overview,How {transforms} work>>.
  23. * <<transform-setup,How to set up {transforms}>>.
  24. * <<transform-checkpoints,How {transform} checkpoints work in continuous mode>>.
  25. The following considerations are not sequential – the numbers help to navigate
  26. between the list items; you can take action on one or more of them in any order.
  27. Most of the recommendations apply to both continuous and batch {transforms}. If
  28. a list item only applies to one {transform} type, this exception is highlighted
  29. in the description.
  30. The keywords in parenthesis at the end of each recommendation title indicates
  31. the bottleneck area that may be improved by following the given recommendation.
  32. [discrete]
  33. [[measure-performance]]
  34. == Measure {transforms} performance
  35. In order to optimize {transform} performance, start by identifying the areas
  36. where most work is being done. The **Stats** interface of the
  37. **{transforms-cap}** page in {kib} contains information that covers three main
  38. areas: indexing, searching, and processing time (alternatively, you can use the
  39. <<get-transform-stats, {transforms} stats API>>). If, for example, the results
  40. show that the highest proportion of time is spent on search, then prioritize
  41. efforts on optimizing the search query of the {transform}. {transforms-cap} also
  42. has https://esrally.readthedocs.io[Rally support] that makes it possible to run
  43. performance checks on {transforms} configurations if it is required. If you
  44. optimized the crucial factors and you still experience performance issues, you
  45. may also want to consider improving your hardware.
  46. [discrete]
  47. [[frequency]]
  48. == 1. Optimize `frequency` (index)
  49. In a {ctransform}, the `frequency` configuration option sets the interval
  50. between checks for changes in the source indices. If changes are detected, then
  51. the source data is searched and the changes are applied to the destination
  52. index. Depending on your use case, you may wish to reduce the frequency at which
  53. changes are applied. By setting `frequency` to a higher value (maximum is one
  54. hour), the workload can be spread over time at the cost of less up-to-date data.
  55. [discrete]
  56. [[increase-shards-dest-index]]
  57. == 2. Increase the number of shards of the destination index (index)
  58. Depending on the size of the destination index, you may consider increasing its
  59. shard count. {transforms-cap} use one shard by default when creating the
  60. destination index. To override the index settings, create the destination index
  61. before starting the {transform}. For more information about how the number of
  62. shards affects scalability and resilience, refer to <<scalability>>
  63. TIP: Use the <<preview-transform>> to check the settings that the {transform}
  64. would use to create the destination index. You can copy and adjust these in
  65. order to create the destination index prior to starting the {transform}.
  66. [discrete]
  67. [[search-queries]]
  68. == 3. Profile and optimize your search queries (search)
  69. If you have defined a {transform} source index `query`, ensure it is as
  70. efficient as possible. Use the **Search Profiler** under **Dev Tools** in {kib}
  71. to get detailed timing information about the execution of individual components
  72. in the search request. Alternatively, you can use the <<search-profile>>. The
  73. results give you insight into how search requests are executed at a low level so
  74. that you can understand why certain requests are slow, and take steps to improve
  75. them.
  76. {transforms-cap} execute standard {es} search requests. There are different ways
  77. to write {es} queries, and some of them are more efficient than others. Consult
  78. <<tune-for-search-speed>> to learn more about {es} performance tuning.
  79. [discrete]
  80. [[limit-source-query]]
  81. == 4. Limit the scope of the source query (search)
  82. Imagine your {ctransform} is configured to group by `IP` and calculate the sum
  83. of `bytes_sent`. For each checkpoint, a {ctransform} detects changes in the
  84. source data since the previous checkpoint, identifying the IPs for which new
  85. data has been ingested. Then it performs a second search, filtered for this
  86. group of IPs, in order to calculate the total `bytes_sent`. If this second
  87. search matches many shards, then this could be resource intensive. Consider
  88. limiting the scope that the source index pattern and query will match.
  89. Use an absolute time value as a date range filter in your source query (for
  90. example, greater than `2020-01-01T00:00:00`) to limit which historical indices
  91. are accessed. If you use a relative time value (for example, `now-30d`) then
  92. this date range is re-evaluated at the point of each checkpoint execution.
  93. [discrete]
  94. [[optimize-shading-strategy]]
  95. == 5. Optimize the sharding strategy for the source index (search)
  96. There is no one-size-fits-all sharding strategy. A strategy that works in one
  97. environment may not scale in another. A good sharding strategy must account for
  98. your infrastructure, use case, and performance expectations.
  99. Too few shards may mean that the benefits of distributing the workload cannot be
  100. realised; however too many shards may impact your cluster health. To learn more
  101. about sizing your shards, read this <<size-your-shards,guide>>.
  102. [discrete]
  103. [[tune-max-page-search-size]]
  104. == 6. Tune `max_page_search_size` (search)
  105. The `max_page_search_size` {transform} configuration option defines the number
  106. of buckets that are returned for each search request. The default value is 500.
  107. If you increase this value, you get better throughput at the cost of higher
  108. latency and memory usage.
  109. The ideal value of this parameter is highly dependent on your use case. If your
  110. {transform} executes memory-intensive aggregations – for example, cardinality or
  111. percentiles – then increasing `max_page_search_size` requires more available
  112. memory. If memory limits are exceeded, a circuit breaker exception occurs.
  113. [discrete]
  114. [[indexed-fields-in-source]]
  115. == 7. Use indexed fields in your source indices (search)
  116. Runtime fields and scripted fields are not indexed fields; their values are only
  117. extracted or computed at search time. While these fields provide flexibility in
  118. how you access your data, they increase performance costs at search time. If
  119. {transform} performance using runtime fields or scripted fields is a concern,
  120. you may wish to consider using indexed fields instead. For performance reasons,
  121. we do not recommend using a runtime field as the time field that synchronizes a
  122. {ctransform}.
  123. [discrete]
  124. [[index-sorting-group-by-ordering]]
  125. == 8. Use index sorting and `group_by` ordering (search, process)
  126. If you use more than one `group_by` field in your {transform}, then the order of
  127. the fields in conjunction with the use of <<index-modules-index-sorting>> may
  128. improve runtime.
  129. Index sorting enables you to store documents on disk in a specific order which
  130. can improve query efficiency. The ideal sorting logic depends on your use case,
  131. but the rule of thumb may be to sort the fields in descending order (high to low
  132. cardinality) starting with the time-based fields. Then put the time-based
  133. components first in the `group_by` if you have any, and then apply the same
  134. order to your `group_by` fields as configured for index sorting. Index sorting
  135. can be defined only once at index creation. If you don't already have index
  136. sorting on the index that you want to use as a source, consider reindexing it to
  137. a new, sorted index.
  138. [discrete]
  139. [[disable-source-dest]]
  140. == 9. Disable the `_source` field on the destination index (storage)
  141. The <<mapping-source-field>> contains the original JSON document body that was
  142. passed at index time. The `_source` field itself is not indexed (and thus is not
  143. searchable), but it is still stored in the index and incurs a storage overhead.
  144. Consider disabling `_source` to save storage space if you have a large
  145. destination index. Disabling `_source` is only possible during index creation.
  146. NOTE: When the `_source` field is disabled, a number of features are not
  147. supported. Consult <<disable-source-field>> to understand the consequences
  148. before disabling it.
  149. [discrete]
  150. == Further reading
  151. * <<tune-for-search-speed>>
  152. * <<tune-for-indexing-speed>>
  153. * <<size-your-shards>>
  154. * <<ilm-index-lifecycle>>