threadpool.asciidoc 6.1 KB

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