repo-analysis-api.asciidoc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. [role="xpack"]
  2. [[repo-analysis-api]]
  3. === Repository analysis API
  4. ++++
  5. <titleabbrev>Repository analysis</titleabbrev>
  6. ++++
  7. Analyzes a repository, reporting its performance characteristics and any
  8. incorrect behaviour found.
  9. ////
  10. [source,console]
  11. ----
  12. PUT /_snapshot/my_repository
  13. {
  14. "type": "fs",
  15. "settings": {
  16. "location": "my_backup_location"
  17. }
  18. }
  19. ----
  20. // TESTSETUP
  21. ////
  22. [source,console]
  23. ----
  24. POST /_snapshot/my_repository/_analyze?blob_count=10&max_blob_size=1mb&timeout=120s
  25. ----
  26. [[repo-analysis-api-request]]
  27. ==== {api-request-title}
  28. `POST /_snapshot/<repository>/_analyze`
  29. [[repo-analysis-api-prereqs]]
  30. ==== {api-prereq-title}
  31. * If the {es} {security-features} are enabled, you must have the `manage`
  32. <<privileges-list-cluster,cluster privilege>> to use this API. For more
  33. information, see <<security-privileges>>.
  34. * If the <<operator-privileges,{operator-feature}>> is enabled, only operator
  35. users can use this API.
  36. [[repo-analysis-api-desc]]
  37. ==== {api-description-title}
  38. There are a large number of third-party storage systems available, not all of
  39. which are suitable for use as a snapshot repository by {es}. Some storage
  40. systems behave incorrectly, or perform poorly, especially when accessed
  41. concurrently by multiple clients as the nodes of an {es} cluster do.
  42. The Repository analysis API performs a collection of read and write operations
  43. on your repository which are designed to detect incorrect behaviour and to
  44. measure the performance characteristics of your storage system.
  45. The default values for the parameters to this API are deliberately low to
  46. reduce the impact of running an analysis inadvertently. A realistic experiment
  47. should set `blob_count` to at least `2000`, `max_blob_size` to at least `2gb`,
  48. and `max_total_data_size` to at least `1tb`, and will almost certainly need to
  49. increase the `timeout` to allow time for the process to complete successfully.
  50. You should run the analysis on a multi-node cluster of a similar size to your
  51. production cluster so that it can detect any problems that only arise when the
  52. repository is accessed by many nodes at once.
  53. If the analysis is successful this API returns details of the testing process,
  54. optionally including how long each operation took. You can use this information
  55. to determine the performance of your storage system. If any operation fails or
  56. returns an incorrect result, this API returns an error. If the API returns an
  57. error then it may not have removed all the data it wrote to the repository. The
  58. error will indicate the location of any leftover data, and this path is also
  59. recorded in the {es} logs. You should verify yourself that this location has
  60. been cleaned up correctly. If there is still leftover data at the specified
  61. location then you should manually remove it.
  62. If the connection from your client to {es} is closed while the client is
  63. waiting for the result of the analysis then the test is cancelled. Some clients
  64. are configured to close their connection if no response is received within a
  65. certain timeout. An analysis takes a long time to complete so you may need to
  66. relax any such client-side timeouts. On cancellation the analysis attempts to
  67. clean up the data it was writing, but it may not be able to remove it all. The
  68. path to the leftover data is recorded in the {es} logs. You should verify
  69. yourself that this location has been cleaned up correctly. If there is still
  70. leftover data at the specified location then you should manually remove it.
  71. If the analysis is successful then it detected no incorrect behaviour, but this
  72. does not mean that correct behaviour is guaranteed. The analysis attempts to
  73. detect common bugs but it certainly does not offer 100% coverage. Additionally,
  74. it does not test the following:
  75. - Your repository must perform durable writes. Once a blob has been written it
  76. must remain in place until it is deleted, even after a power loss or similar
  77. disaster.
  78. - Your repository must not suffer from silent data corruption. Once a blob has
  79. been written its contents must remain unchanged until it is deliberately
  80. modified or deleted.
  81. - Your repository must behave correctly even if connectivity from the cluster
  82. is disrupted. Reads and writes may fail in this case, but they must not return
  83. incorrect results.
  84. IMPORTANT: An analysis writes a substantial amount of data to your repository
  85. and then reads it back again. This consumes bandwidth on the network between
  86. the cluster and the repository, and storage space and IO bandwidth on the
  87. repository itself. You must ensure this load does not affect other users of
  88. these systems. Analyses respect the repository settings
  89. `max_snapshot_bytes_per_sec` and `max_restore_bytes_per_sec` if available, and
  90. the cluster setting `indices.recovery.max_bytes_per_sec` which you can use to
  91. limit the bandwidth they consume.
  92. NOTE: This API is intended for exploratory use by humans. You should expect the
  93. request parameters and the response format to vary in future versions.
  94. NOTE: This API may not work correctly in a mixed-version cluster.
  95. ==== Implementation details
  96. NOTE: This section of documentation describes how the Repository analysis API
  97. works in this version of {es}, but you should expect the implementation to vary
  98. between versions. The request parameters and response format depend on details
  99. of the implementation so may also be different in newer versions.
  100. The analysis comprises a number of blob-level tasks, as set by the `blob_count`
  101. parameter. The blob-level tasks are distributed over the data and
  102. master-eligible nodes in the cluster for execution.
  103. For most blob-level tasks, the executing node first writes a blob to the
  104. repository, and then instructs some of the other nodes in the cluster to
  105. attempt to read the data it just wrote. The size of the blob is chosen
  106. randomly, according to the `max_blob_size` and `max_total_data_size`
  107. parameters. If any of these reads fails then the repository does not implement
  108. the necessary read-after-write semantics that {es} requires.
  109. For some blob-level tasks, the executing node will instruct some of its peers
  110. to attempt to read the data before the writing process completes. These reads
  111. are permitted to fail, but must not return partial data. If any read returns
  112. partial data then the repository does not implement the necessary atomicity
  113. semantics that {es} requires.
  114. For some blob-level tasks, the executing node will overwrite the blob while its
  115. peers are reading it. In this case the data read may come from either the
  116. original or the overwritten blob, but the read operation must not return
  117. partial data or a mix of data from the two blobs. If any of these reads returns
  118. partial data or a mix of the two blobs then the repository does not implement
  119. the necessary atomicity semantics that {es} requires for overwrites.
  120. The executing node will use a variety of different methods to write the blob.
  121. For instance, where applicable, it will use both single-part and multi-part
  122. uploads. Similarly, the reading nodes will use a variety of different methods
  123. to read the data back again. For instance they may read the entire blob from
  124. start to end, or may read only a subset of the data.
  125. [[repo-analysis-api-path-params]]
  126. ==== {api-path-parms-title}
  127. `<repository>`::
  128. (Required, string)
  129. Name of the snapshot repository to test.
  130. [[repo-analysis-api-query-params]]
  131. ==== {api-query-parms-title}
  132. `blob_count`::
  133. (Optional, integer) The total number of blobs to write to the repository during
  134. the test. Defaults to `100`. For realistic experiments you should set this to
  135. at least `2000`.
  136. `max_blob_size`::
  137. (Optional, <<size-units, size units>>) The maximum size of a blob to be written
  138. during the test. Defaults to `10mb`. For realistic experiments you should set
  139. this to at least `2gb`.
  140. `max_total_data_size`::
  141. (Optional, <<size-units, size units>>) An upper limit on the total size of all
  142. the blobs written during the test. Defaults to `1gb`. For realistic experiments
  143. you should set this to at least `1tb`.
  144. `timeout`::
  145. (Optional, <<time-units, time units>>) Specifies the period of time to wait for
  146. the test to complete. If no response is received before the timeout expires,
  147. the test is cancelled and returns an error. Defaults to `30s`.
  148. ===== Advanced query parameters
  149. The following parameters allow additional control over the analysis, but you
  150. will usually not need to adjust them.
  151. `concurrency`::
  152. (Optional, integer) The number of write operations to perform concurrently.
  153. Defaults to `10`.
  154. `read_node_count`::
  155. (Optional, integer) The number of nodes on which to perform a read operation
  156. after writing each blob. Defaults to `10`.
  157. `early_read_node_count`::
  158. (Optional, integer) The number of nodes on which to perform an early read
  159. operation while writing each blob. Defaults to `2`. Early read operations are
  160. only rarely performed.
  161. `rare_action_probability`::
  162. (Optional, double) The probability of performing a rare action (an early read
  163. or an overwrite) on each blob. Defaults to `0.02`.
  164. `seed`::
  165. (Optional, integer) The seed for the pseudo-random number generator used to
  166. generate the list of operations performed during the test. To repeat the same
  167. set of operations in multiple experiments, use the same seed in each
  168. experiment. Note that the operations are performed concurrently so may not
  169. always happen in the same order on each run.
  170. `detailed`::
  171. (Optional, boolean) Whether to return detailed results, including timing
  172. information for every operation performed during the analysis. Defaults to
  173. `false`, meaning to return only a summary of the analysis.
  174. [role="child_attributes"]
  175. [[repo-analysis-api-response-body]]
  176. ==== {api-response-body-title}
  177. The response exposes implementation details of the analysis which may change
  178. from version to version. The response body format is therefore not considered
  179. stable and may be different in newer versions.
  180. `coordinating_node`::
  181. (object)
  182. Identifies the node which coordinated the analysis and performed the final cleanup.
  183. +
  184. .Properties of `coordinating_node`
  185. [%collapsible%open]
  186. ====
  187. `id`::
  188. (string)
  189. The id of the coordinating node.
  190. `name`::
  191. (string)
  192. The name of the coordinating node
  193. ====
  194. `repository`::
  195. (string)
  196. The name of the repository that was the subject of the analysis.
  197. `blob_count`::
  198. (integer)
  199. The number of blobs written to the repository during the test, equal to the
  200. `?blob_count` request parameter.
  201. `concurrency`::
  202. (integer)
  203. The number of write operations performed concurrently during the test, equal to
  204. the `?concurrency` request parameter.
  205. `read_node_count`::
  206. (integer)
  207. The limit on the number of nodes on which read operations were performed after
  208. writing each blob, equal to the `?read_node_count` request parameter.
  209. `early_read_node_count`::
  210. (integer)
  211. The limit on the number of nodes on which early read operations were performed
  212. after writing each blob, equal to the `?early_read_node_count` request
  213. parameter.
  214. `max_blob_size`::
  215. (string)
  216. The limit on the size of a blob written during the test, equal to the
  217. `?max_blob_size` parameter.
  218. `max_blob_size_bytes`::
  219. (long)
  220. The limit, in bytes, on the size of a blob written during the test, equal to
  221. the `?max_blob_size` parameter.
  222. `max_total_data_size`::
  223. (string)
  224. The limit on the total size of all blob written during the test, equal to the
  225. `?max_total_data_size` parameter.
  226. `max_total_data_size_bytes`::
  227. (long)
  228. The limit, in bytes, on the total size of all blob written during the test,
  229. equal to the `?max_total_data_size` parameter.
  230. `seed`::
  231. (long)
  232. The seed for the pseudo-random number generator used to generate the operations
  233. used during the test. Equal to the `?seed` request parameter if set.
  234. `rare_action_probability`::
  235. (double)
  236. The probability of performing rare actions during the test. Equal to the
  237. `?rare_action_probability` request parameter.
  238. `blob_path`::
  239. (string)
  240. The path in the repository under which all the blobs were written during the
  241. test.
  242. `issues_detected`::
  243. (list)
  244. A list of correctness issues detected, which will be empty if the API
  245. succeeded. Included to emphasize that a successful response does not guarantee
  246. correct behaviour in future.
  247. `summary`::
  248. (object)
  249. A collection of statistics that summarise the results of the test.
  250. +
  251. .Properties of `summary`
  252. [%collapsible%open]
  253. ====
  254. `write`::
  255. (object)
  256. A collection of statistics that summarise the results of the write operations
  257. in the test.
  258. +
  259. .Properties of `write`
  260. [%collapsible%open]
  261. =====
  262. `count`::
  263. (integer)
  264. The number of write operations performed in the test.
  265. `total_size`::
  266. (string)
  267. The total size of all the blobs written in the test.
  268. `total_size_bytes`::
  269. (long)
  270. The total size of all the blobs written in the test, in bytes.
  271. `total_throttled`::
  272. (string)
  273. The total time spent waiting due to the `max_snapshot_bytes_per_sec` throttle.
  274. `total_throttled_nanos`::
  275. (long)
  276. The total time spent waiting due to the `max_snapshot_bytes_per_sec` throttle,
  277. in nanoseconds.
  278. `total_elapsed`::
  279. (string)
  280. The total elapsed time spent on writing blobs in the test.
  281. `total_elapsed_nanos`::
  282. (long)
  283. The total elapsed time spent on writing blobs in the test, in nanoseconds.
  284. =====
  285. `read`::
  286. (object)
  287. A collection of statistics that summarise the results of the read operations in
  288. the test.
  289. +
  290. .Properties of `read`
  291. [%collapsible%open]
  292. =====
  293. `count`::
  294. (integer)
  295. The number of read operations performed in the test.
  296. `total_size`::
  297. (string)
  298. The total size of all the blobs or partial blobs read in the test.
  299. `total_size_bytes`::
  300. (long)
  301. The total size of all the blobs or partial blobs read in the test, in bytes.
  302. `total_wait`::
  303. (string)
  304. The total time spent waiting for the first byte of each read request to be
  305. received.
  306. `total_wait_nanos`::
  307. (long)
  308. The total time spent waiting for the first byte of each read request to be
  309. received, in nanoseconds.
  310. `max_wait`::
  311. (string)
  312. The maximum time spent waiting for the first byte of any read request to be
  313. received.
  314. `max_wait_nanos`::
  315. (long)
  316. The maximum time spent waiting for the first byte of any read request to be
  317. received, in nanoseconds.
  318. `total_throttled`::
  319. (string)
  320. The total time spent waiting due to the `max_restore_bytes_per_sec` or
  321. `indices.recovery.max_bytes_per_sec` throttles.
  322. `total_throttled_nanos`::
  323. (long)
  324. The total time spent waiting due to the `max_restore_bytes_per_sec` or
  325. `indices.recovery.max_bytes_per_sec` throttles, in nanoseconds.
  326. `total_elapsed`::
  327. (string)
  328. The total elapsed time spent on reading blobs in the test.
  329. `total_elapsed_nanos`::
  330. (long)
  331. The total elapsed time spent on reading blobs in the test, in nanoseconds.
  332. =====
  333. ====
  334. `details`::
  335. (array)
  336. A description of every read and write operation performed during the test. This
  337. is only returned if the `?detailed` request parameter is set to `true`.
  338. +
  339. .Properties of items within `details`
  340. [%collapsible]
  341. ====
  342. `blob`::
  343. (object)
  344. A description of the blob that was written and read.
  345. +
  346. .Properties of `blob`
  347. [%collapsible%open]
  348. =====
  349. `name`::
  350. (string)
  351. The name of the blob.
  352. `size`::
  353. (string)
  354. The size of the blob.
  355. `size_bytes`::
  356. (long)
  357. The size of the blob in bytes.
  358. `read_start`::
  359. (long)
  360. The position, in bytes, at which read operations started.
  361. `read_end`::
  362. (long)
  363. The position, in bytes, at which read operations completed.
  364. `read_early`::
  365. (boolean)
  366. Whether any read operations were started before the write operation completed.
  367. `overwritten`::
  368. (boolean)
  369. Whether the blob was overwritten while the read operations were ongoing.
  370. =====
  371. `writer_node`::
  372. (object)
  373. Identifies the node which wrote this blob and coordinated the read operations.
  374. +
  375. .Properties of `writer_node`
  376. [%collapsible%open]
  377. =====
  378. `id`::
  379. (string)
  380. The id of the writer node.
  381. `name`::
  382. (string)
  383. The name of the writer node
  384. =====
  385. `write_elapsed`::
  386. (string)
  387. The elapsed time spent writing this blob.
  388. `write_elapsed_nanos`::
  389. (long)
  390. The elapsed time spent writing this blob, in nanoseconds.
  391. `overwrite_elapsed`::
  392. (string)
  393. The elapsed time spent overwriting this blob. Omitted if the blob was not
  394. overwritten.
  395. `overwrite_elapsed_nanos`::
  396. (long)
  397. The elapsed time spent overwriting this blob, in nanoseconds. Omitted if the
  398. blob was not overwritten.
  399. `write_throttled`::
  400. (string)
  401. The length of time spent waiting for the `max_snapshot_bytes_per_sec` throttle
  402. while writing this blob.
  403. `write_throttled_nanos`::
  404. (long)
  405. The length of time spent waiting for the `max_snapshot_bytes_per_sec` throttle
  406. while writing this blob, in nanoseconds.
  407. `reads`::
  408. (array)
  409. A description of every read operation performed on this blob.
  410. +
  411. .Properties of items within `reads`
  412. [%collapsible%open]
  413. =====
  414. `node`::
  415. (object)
  416. Identifies the node which performed the read operation.
  417. +
  418. .Properties of `node`
  419. [%collapsible%open]
  420. ======
  421. `id`::
  422. (string)
  423. The id of the reader node.
  424. `name`::
  425. (string)
  426. The name of the reader node
  427. ======
  428. `before_write_complete`::
  429. (boolean)
  430. Whether the read operation may have started before the write operation was
  431. complete. Omitted if `false`.
  432. `found`::
  433. (boolean)
  434. Whether the blob was found by this read operation or not. May be `false` if the
  435. read was started before the write completed.
  436. `first_byte_time`::
  437. (string)
  438. The length of time waiting for the first byte of the read operation to be
  439. received. Omitted if the blob was not found.
  440. `first_byte_time_nanos`::
  441. (long)
  442. The length of time waiting for the first byte of the read operation to be
  443. received, in nanoseconds. Omitted if the blob was not found.
  444. `elapsed`::
  445. (string)
  446. The length of time spent reading this blob. Omitted if the blob was not found.
  447. `elapsed_nanos`::
  448. (long)
  449. The length of time spent reading this blob, in nanoseconds. Omitted if the blob
  450. was not found.
  451. `throttled`::
  452. (string)
  453. The length of time spent waiting due to the `max_restore_bytes_per_sec` or
  454. `indices.recovery.max_bytes_per_sec` throttles during the read of this blob.
  455. Omitted if the blob was not found.
  456. `throttled_nanos`::
  457. (long)
  458. The length of time spent waiting due to the `max_restore_bytes_per_sec` or
  459. `indices.recovery.max_bytes_per_sec` throttles during the read of this blob, in
  460. nanoseconds. Omitted if the blob was not found.
  461. =====
  462. ====
  463. `listing_elapsed`::
  464. (string)
  465. The time it took to retrieve a list of all the blobs in the container.
  466. `listing_elapsed_nanos`::
  467. (long)
  468. The time it took to retrieve a list of all the blobs in the container, in
  469. nanoseconds.
  470. `delete_elapsed`::
  471. (string)
  472. The time it took to delete all the blobs in the container.
  473. `delete_elapsed_nanos`::
  474. (long)
  475. The time it took to delete all the blobs in the container, in nanoseconds.