threadpool.asciidoc 5.7 KB

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