benchmark.asciidoc 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. [[search-benchmark]]
  2. == Benchmark
  3. added[1.4.0]
  4. .Experimental!
  5. [IMPORTANT]
  6. =====
  7. This feature is marked as experimental, and may be subject to change in the
  8. future. If you use this feature, please let us know your experience with it!
  9. =====
  10. The benchmark API provides a standard mechanism for submitting queries and
  11. measuring their performance relative to one another.
  12. [IMPORTANT]
  13. =====
  14. To be eligible to run benchmarks nodes must be started with: `--node.bench true`. This is just a way to mark certain nodes as "executors". Searches will still be distributed out to the cluster in the normal manner. This is primarily a defensive measure to prevent production nodes from being flooded with potentially many requests. Typically one would start a single node with this setting and submit benchmark requests to it.
  15. =====
  16. [source,bash]
  17. --------------------------------------------------
  18. $ ./bin/elasticsearch --node.bench true
  19. --------------------------------------------------
  20. Benchmarking a search request is as simple as executing the following command:
  21. [source,js]
  22. --------------------------------------------------
  23. $ curl -XPUT 'localhost:9200/_bench/?pretty=true' -d '{
  24. "name": "my_benchmark",
  25. "competitors": [ {
  26. "name": "my_competitor",
  27. "requests": [ {
  28. "query": {
  29. "match": { "_all": "a*" }
  30. }
  31. } ]
  32. } ]
  33. }'
  34. --------------------------------------------------
  35. Response:
  36. [source,js]
  37. --------------------------------------------------
  38. {
  39. "status" : "complete",
  40. "competitors" : {
  41. "my_competitor" : {
  42. "summary" : {
  43. "nodes" : [ "localhost" ],
  44. "total_iterations" : 5,
  45. "completed_iterations" : 5,
  46. "total_queries" : 1000,
  47. "concurrency" : 5,
  48. "multiplier" : 100,
  49. "avg_warmup_time" : 43.0,
  50. "statistics" : {
  51. "min" : 1,
  52. "max" : 10,
  53. "mean" : 4.19,
  54. "qps" : 238.663,
  55. "std_dev" : 1.938,
  56. "millis_per_hit" : 1.064,
  57. "percentile_10" : 2,
  58. "percentile_25" : 3,
  59. "percentile_50" : 4,
  60. "percentile_75" : 5,
  61. "percentile_90" : 7,
  62. "percentile_99" : 10
  63. }
  64. }
  65. }
  66. }
  67. }
  68. --------------------------------------------------
  69. A 'competitor' defines one or more search requests to execute along with parameters that describe how the search(es) should be run.
  70. Multiple competitors may be submitted as a group in which case they will execute one after the other. This makes it easy to compare various
  71. competing alternatives side-by-side.
  72. There are several parameters which may be set at the competition level:
  73. [horizontal]
  74. `name`:: Unique name for the competition.
  75. `iterations`:: Number of times to run the competitors. Defaults to `5`.
  76. `concurrency`:: Within each iteration use this level of parallelism. Defaults to `5`.
  77. `multiplier`:: Within each iteration run the query this many times. Defaults to `1000`.
  78. `warmup`:: Perform warmup of query. Defaults to `true`.
  79. `num_slowest`:: Record N slowest queries. Defaults to `1`.
  80. `search_type`:: Type of search, e.g. "query_then_fetch", "dfs_query_then_fetch", "count". Defaults to `query_then_fetch`.
  81. `requests`:: Query DSL describing search requests.
  82. `clear_caches`:: Whether caches should be cleared on each iteration, and if so, how. Caches are not cleared by default.
  83. `indices`:: Array of indices to search, e.g. ["my_index_1", "my_index_2", "my_index_3"].
  84. `types`:: Array of index types to search, e.g. ["my_type_1", "my_type_2"].
  85. Cache clearing parameters:
  86. [horizontal]
  87. `clear_caches`:: Set to 'false' to disable cache clearing completely.
  88. `clear_caches.filter`:: Whether to clear the filter cache.
  89. `clear_caches.field_data`:: Whether to clear the field data cache.
  90. `clear_caches.id`:: Whether to clear the id cache.
  91. `clear_caches.recycler`:: Whether to clear the recycler cache.
  92. `clear_caches.fields`:: Array of fields to clear.
  93. `clear_caches.filter_keys`:: Array of filter keys to clear.
  94. Global parameters:
  95. [horizontal]
  96. `name`:: Unique name for the benchmark.
  97. `num_executor_nodes`:: Number of cluster nodes from which to submit and time benchmarks. Allows user to run a benchmark simultaneously on one or more nodes and compare timings. Note that this does not control how many nodes a search request will actually execute on. Defaults to: 1.
  98. `percentiles`:: Array of percentile values to report. Defaults to: [10, 25, 50, 75, 90, 99].
  99. Additionally, the following competition-level parameters may be set globally: iteration, concurrency, multiplier, warmup, and clear_caches.
  100. Using these parameters it is possible to describe precisely how to execute a benchmark under various conditions. In the following example we run a filtered query against two different indices using two different search types.
  101. [source,js]
  102. --------------------------------------------------
  103. $ curl -XPUT 'localhost:9200/_bench/?pretty=true' -d '{
  104. "name": "my_benchmark",
  105. "num_executor_nodes": 1,
  106. "percentiles" : [ 25, 50, 75 ],
  107. "iterations": 5,
  108. "multiplier": 1000,
  109. "concurrency": 5,
  110. "num_slowest": 0,
  111. "warmup": true,
  112. "clear_caches": false,
  113. "requests": [ {
  114. "query" : {
  115. "filtered" : {
  116. "query" : { "match" : { "_all" : "*" } },
  117. "filter" : {
  118. "and" : [ { "term" : { "title" : "Spain" } },
  119. { "term" : { "title" : "rain" } },
  120. { "term" : { "title" : "plain" } } ]
  121. }
  122. }
  123. }
  124. } ],
  125. "competitors": [ {
  126. "name": "competitor_1",
  127. "search_type": "query_then_fetch",
  128. "indices": [ "my_index_1" ],
  129. "types": [ "my_type_1" ],
  130. "clear_caches" : {
  131. "filter" : true,
  132. "field_data" : true,
  133. "id" : true,
  134. "recycler" : true,
  135. "fields": ["title"]
  136. }
  137. }, {
  138. "name": "competitor_2",
  139. "search_type": "dfs_query_then_fetch",
  140. "indices": [ "my_index_2" ],
  141. "types": [ "my_type_2" ],
  142. "clear_caches" : {
  143. "filter" : true,
  144. "field_data" : true,
  145. "id" : true,
  146. "recycler" : true,
  147. "fields": ["title"]
  148. }
  149. } ]
  150. }'
  151. --------------------------------------------------
  152. Response:
  153. [source,js]
  154. --------------------------------------------------
  155. {
  156. "status" : "complete",
  157. "competitors" : {
  158. "competitor_1" : {
  159. "summary" : {
  160. "nodes" : [ "localhost" ],
  161. "total_iterations" : 5,
  162. "completed_iterations" : 5,
  163. "total_queries" : 5000,
  164. "concurrency" : 5,
  165. "multiplier" : 1000,
  166. "avg_warmup_time" : 54.0,
  167. "statistics" : {
  168. "min" : 0,
  169. "max" : 3,
  170. "mean" : 0.533,
  171. "qps" : 1872.659,
  172. "std_dev" : 0.528,
  173. "millis_per_hit" : 0.0,
  174. "percentile_25" : 0.0,
  175. "percentile_50" : 1.0,
  176. "percentile_75" : 1.0
  177. }
  178. }
  179. },
  180. "competitor_2" : {
  181. "summary" : {
  182. "nodes" : [ "localhost" ],
  183. "total_iterations" : 5,
  184. "completed_iterations" : 5,
  185. "total_queries" : 5000,
  186. "concurrency" : 5,
  187. "multiplier" : 1000,
  188. "avg_warmup_time" : 4.0,
  189. "statistics" : {
  190. "min" : 0,
  191. "max" : 4,
  192. "mean" : 0.487,
  193. "qps" : 2049.180,
  194. "std_dev" : 0.545,
  195. "millis_per_hit" : 0.0,
  196. "percentile_25" : 0.0,
  197. "percentile_50" : 0.0,
  198. "percentile_75" : 1.0
  199. }
  200. }
  201. }
  202. }
  203. }
  204. --------------------------------------------------
  205. In some cases it may be desirable to view the progress of a long-running benchmark and optionally terminate it early. To view all active benchmarks use:
  206. [source,js]
  207. --------------------------------------------------
  208. $ curl -XGET 'localhost:9200/_bench?pretty'
  209. --------------------------------------------------
  210. This would display run-time statistics in the same format as the sample output above.
  211. To abort a long-running benchmark use the 'abort' endpoint:
  212. [source,js]
  213. --------------------------------------------------
  214. $ curl -XPOST 'localhost:9200/_bench/abort/my_benchmark?pretty'
  215. --------------------------------------------------
  216. Response:
  217. [source,js]
  218. --------------------------------------------------
  219. {
  220. "aborted_benchmarks" : [
  221. "node" "localhost",
  222. "benchmark_name", "my_benchmark",
  223. "aborted", true
  224. ]
  225. }
  226. --------------------------------------------------