threadpool.asciidoc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. `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 `10000`. The maximum size for this pool is
  29. `pass:[1 + ]`<<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 `pass:[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 `pass:[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. `system_read`::
  67. For read operations on system indices.
  68. Thread pool type is `fixed` and a default maximum size of
  69. `min(5, (`<<node.processors, `# of allocated processors`>>`) / 2)`.
  70. Changing a specific thread pool can be done by setting its type-specific
  71. parameters; for example, changing the number of threads in the `write` thread
  72. pool:
  73. [source,yaml]
  74. --------------------------------------------------
  75. thread_pool:
  76. write:
  77. size: 30
  78. --------------------------------------------------
  79. [[thread-pool-types]]
  80. ==== Thread pool types
  81. The following are the types of thread pools and their respective parameters:
  82. [[fixed-thread-pool]]
  83. ===== `fixed`
  84. The `fixed` thread pool holds a fixed size of threads to handle the
  85. requests with a queue (optionally bounded) for pending requests that
  86. have no threads to service them.
  87. The `size` parameter controls the number of threads.
  88. The `queue_size` allows to control the size of the queue of pending
  89. requests that have no threads to execute them. By default, it is set to
  90. `-1` which means its unbounded. When a request comes in and the queue is
  91. full, it will abort the request.
  92. [source,yaml]
  93. --------------------------------------------------
  94. thread_pool:
  95. write:
  96. size: 30
  97. queue_size: 1000
  98. --------------------------------------------------
  99. [[scaling-thread-pool]]
  100. ===== `scaling`
  101. The `scaling` thread pool holds a dynamic number of threads. This
  102. number is proportional to the workload and varies between the value of
  103. the `core` and `max` parameters.
  104. The `keep_alive` parameter determines how long a thread should be kept
  105. around in the thread pool without it doing any work.
  106. [source,yaml]
  107. --------------------------------------------------
  108. thread_pool:
  109. warmer:
  110. core: 1
  111. max: 8
  112. keep_alive: 2m
  113. --------------------------------------------------
  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.