1
0

threadpool.asciidoc 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. [[modules-threadpool]]
  2. === Thread pools
  3. A node uses several thread pools to manage memory consumption.
  4. Queues associated with many of the thread pools enable pending requests
  5. to be held instead of discarded.
  6. There are several thread pools, but the important ones include:
  7. `generic`::
  8. For generic operations (for example, background node discovery).
  9. Thread pool type is `scaling`.
  10. [[search-threadpool]]
  11. `search`::
  12. For count/search/suggest operations. Thread pool type is
  13. `fixed` with a size of `int((`<<node.processors,
  14. `# of allocated processors`>>`pass:[ * ]3) / 2) + 1`, and queue_size of `1000`.
  15. [[search-throttled]]`search_throttled`::
  16. For count/search/suggest/get operations on `search_throttled indices`.
  17. Thread pool type is `fixed` with a size of `1`, and queue_size of `100`.
  18. `search_coordination`::
  19. For lightweight search-related coordination operations. Thread pool type is
  20. `fixed` with a size of a max of `min(5, (`<<node.processors,
  21. `# of allocated processors`>>`) / 2)`, and queue_size of `1000`.
  22. `get`::
  23. For get operations. Thread pool type is `fixed`
  24. with a size of <<node.processors, `# of allocated processors`>>,
  25. queue_size of `1000`.
  26. `analyze`::
  27. For analyze requests. Thread pool type is `fixed` with a size of `1`, queue
  28. size of `16`.
  29. `write`::
  30. For single-document index/delete/update and bulk requests. Thread pool type
  31. is `fixed` with a size of <<node.processors, `# of allocated processors`>>,
  32. queue_size of `10000`. The maximum size for this pool is
  33. `pass:[1 + ]`<<node.processors, `# of allocated processors`>>.
  34. `snapshot`::
  35. For snapshot/restore operations. Thread pool type is `scaling` with a
  36. keep-alive of `5m` and a max of `min(5, (`<<node.processors,
  37. `# of allocated processors`>>`) / 2)`.
  38. `snapshot_meta`::
  39. For snapshot repository metadata read operations. Thread pool type is `scaling` with a
  40. keep-alive of `5m` and a max of `min(50, (`<<node.processors,
  41. `# of allocated processors`>>`* 3))`.
  42. `warmer`::
  43. For segment warm-up operations. Thread pool type is `scaling` with a
  44. keep-alive of `5m` and a max of `min(5, (`<<node.processors,
  45. `# of allocated processors`>>`) / 2)`.
  46. `refresh`::
  47. For refresh operations. Thread pool type is `scaling` with a
  48. keep-alive of `5m` and a max of `min(10, (`<<node.processors,
  49. `# of allocated processors`>>`) / 2)`.
  50. `fetch_shard_started`::
  51. For listing shard states.
  52. Thread pool type is `scaling` with keep-alive of `5m` and a default maximum
  53. size of `pass:[2 * ]`<<node.processors, `# of allocated processors`>>.
  54. `fetch_shard_store`::
  55. For listing shard stores.
  56. Thread pool type is `scaling` with keep-alive of `5m` and a default maximum
  57. size of `pass:[2 * ]`<<node.processors, `# of allocated processors`>>.
  58. `flush`::
  59. For <<indices-flush,flush>> and <<index-modules-translog, translog>> `fsync`
  60. operations. Thread pool type is `scaling` with a keep-alive of `5m` and a
  61. default maximum size of `min(5, (`<<node.processors,
  62. `# of allocated processors`>>`) / 2)`.
  63. `force_merge`::
  64. For <<indices-forcemerge,force merge>> operations.
  65. Thread pool type is `fixed` with a size of 1 and an unbounded queue size.
  66. `management`::
  67. For cluster management.
  68. Thread pool type is `scaling` with a keep-alive of `5m` and a default
  69. maximum size of `5`.
  70. `system_read`::
  71. For read operations on system indices.
  72. Thread pool type is `fixed` with a default maximum size of
  73. `min(5, (`<<node.processors, `# of allocated processors`>>`) / 2)`.
  74. `system_write`::
  75. For write operations on system indices.
  76. Thread pool type is `fixed` with a default maximum size of
  77. `min(5, (`<<node.processors, `# of allocated processors`>>`) / 2)`.
  78. `system_critical_read`::
  79. For critical read operations on system indices.
  80. Thread pool type is `fixed` with a default maximum size of
  81. `min(5, (`<<node.processors, `# of allocated processors`>>`) / 2)`.
  82. `system_critical_write`::
  83. For critical write operations on system indices.
  84. Thread pool type is `fixed` with a default maximum size of
  85. `min(5, (`<<node.processors, `# of allocated processors`>>`) / 2)`.
  86. `watcher`::
  87. For <<xpack-alerting,watch executions>>.
  88. Thread pool type is `fixed` with a default maximum size of
  89. `min(5 * (`<<node.processors, `# of allocated processors`>>`), 50)`
  90. and queue_size of `1000`.
  91. Thread pool settings are <<static-cluster-setting,static>> and can be changed by
  92. editing `elasticsearch.yml`. Changing a specific thread pool can be done by
  93. setting its type-specific parameters; for example, changing the number of
  94. threads in the `write` thread pool:
  95. [source,yaml]
  96. --------------------------------------------------
  97. thread_pool:
  98. write:
  99. size: 30
  100. --------------------------------------------------
  101. [[thread-pool-types]]
  102. ==== Thread pool types
  103. The following are the types of thread pools and their respective parameters:
  104. [[fixed-thread-pool]]
  105. ===== `fixed`
  106. The `fixed` thread pool holds a fixed size of threads to handle the
  107. requests with a queue (optionally bounded) for pending requests that
  108. have no threads to service them.
  109. The `size` parameter controls the number of threads.
  110. The `queue_size` allows to control the size of the queue of pending
  111. requests that have no threads to execute them. By default, it is set to
  112. `-1` which means its unbounded. When a request comes in and the queue is
  113. full, it will abort the request.
  114. [source,yaml]
  115. --------------------------------------------------
  116. thread_pool:
  117. write:
  118. size: 30
  119. queue_size: 1000
  120. --------------------------------------------------
  121. [[scaling-thread-pool]]
  122. ===== `scaling`
  123. The `scaling` thread pool holds a dynamic number of threads. This
  124. number is proportional to the workload and varies between the value of
  125. the `core` and `max` parameters.
  126. The `keep_alive` parameter determines how long a thread should be kept
  127. around in the thread pool without it doing any work.
  128. [source,yaml]
  129. --------------------------------------------------
  130. thread_pool:
  131. warmer:
  132. core: 1
  133. max: 8
  134. keep_alive: 2m
  135. --------------------------------------------------
  136. [[node.processors]]
  137. ==== Allocated processors setting
  138. The number of processors is automatically detected, and the thread pool settings
  139. are automatically set based on it. In some cases it can be useful to override
  140. the number of detected processors. This can be done by explicitly setting the
  141. `node.processors` setting.
  142. [source,yaml]
  143. --------------------------------------------------
  144. node.processors: 2
  145. --------------------------------------------------
  146. There are a few use-cases for explicitly overriding the `node.processors`
  147. setting:
  148. . If you are running multiple instances of {es} on the same host but want
  149. {es} to size its thread pools as if it only has a fraction of the CPU, you
  150. should override the `node.processors` setting to the desired fraction, for
  151. example, if you're running two instances of {es} on a 16-core machine, set
  152. `node.processors` to 8. Note that this is an expert-level use case and there's
  153. a lot more involved than just setting the `node.processors` setting as there are
  154. other considerations like changing the number of garbage collector threads,
  155. pinning processes to cores, and so on.
  156. . Sometimes the number of processors is wrongly detected and in such cases
  157. explicitly setting the `node.processors` setting will workaround such issues.
  158. In order to check the number of processors detected, use the nodes info
  159. API with the `os` flag.