threadpool.asciidoc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 (e.g., background node discovery).
  10. Thread pool type is `cached`.
  11. `index`::
  12. For index/delete operations. Thread pool type is `fixed`
  13. with a size of `# of available processors`,
  14. queue_size of `200`.
  15. `search`::
  16. For count/search operations. Thread pool type is `fixed`
  17. with a size of `int((# of available_processors * 3) / 2) + 1`,
  18. queue_size of `1000`.
  19. `suggest`::
  20. For suggest operations. Thread pool type is `fixed`
  21. with a size of `# of available processors`,
  22. queue_size of `1000`.
  23. `get`::
  24. For get operations. Thread pool type is `fixed`
  25. with a size of `# of available processors`,
  26. queue_size of `1000`.
  27. `bulk`::
  28. For bulk operations. Thread pool type is `fixed`
  29. with a size of `# of available processors`,
  30. queue_size of `50`.
  31. `percolate`::
  32. For percolate operations. Thread pool type is `fixed`
  33. with a size of `# of available processors`,
  34. queue_size of `1000`.
  35. `snapshot`::
  36. For snapshot/restore operations. Thread pool type is `scaling` with a
  37. keep-alive of `5m` and a size of `min(5, (# of available processors)/2)`.
  38. `warmer`::
  39. For segment warm-up operations. Thread pool type is `scaling` with a
  40. keep-alive of `5m` and a size of `min(5, (# of available processors)/2)`.
  41. `refresh`::
  42. For refresh operations. Thread pool type is `scaling` with a
  43. keep-alive of `5m` and a size of `min(10, (# of available processors)/2)`.
  44. `listener`::
  45. Mainly for java client executing of action when listener threaded is set to true.
  46. Thread pool type is `scaling` with a default size of `min(10, (# of available processors)/2)`.
  47. Changing a specific thread pool can be done by setting its type-specific parameters; for example, changing the `index`
  48. thread pool to have more threads:
  49. [source,js]
  50. --------------------------------------------------
  51. threadpool:
  52. index:
  53. size: 30
  54. --------------------------------------------------
  55. NOTE: you can update thread pool settings dynamically using <<cluster-update-settings>>.
  56. [float]
  57. [[types]]
  58. === Thread pool types
  59. The following are the types of thread pools and their respective parameters:
  60. [float]
  61. ==== `cached`
  62. The `cached` thread pool is an unbounded thread pool that will spawn a
  63. thread if there are pending requests. This thread pool is used to
  64. prevent requests submitted to this pool from blocking or being
  65. rejected. Unused threads in this thread pool will be terminated after
  66. a keep alive expires (defaults to five minutes). The `cached` thread
  67. pool is reserved for the <<modules-threadpool,`generic`>> thread pool.
  68. The `keep_alive` parameter determines how long a thread should be kept
  69. around in the thread pool without doing any work.
  70. [source,js]
  71. --------------------------------------------------
  72. threadpool:
  73. generic:
  74. keep_alive: 2m
  75. --------------------------------------------------
  76. [float]
  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, and defaults to the
  82. number of cores times 5.
  83. The `queue_size` allows to control the size of the queue of pending
  84. requests that have no threads to execute them. By default, it is set to
  85. `-1` which means its unbounded. When a request comes in and the queue is
  86. full, it will abort the request.
  87. [source,js]
  88. --------------------------------------------------
  89. threadpool:
  90. index:
  91. size: 30
  92. queue_size: 1000
  93. --------------------------------------------------
  94. [float]
  95. ==== `scaling`
  96. The `scaling` thread pool holds a dynamic number of threads. This number is
  97. proportional to the workload and varies between 1 and the value of the
  98. `size` parameter.
  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,js]
  102. --------------------------------------------------
  103. threadpool:
  104. warmer:
  105. size: 8
  106. keep_alive: 2m
  107. --------------------------------------------------
  108. [float]
  109. [[processors]]
  110. === Processors setting
  111. The number of processors is automatically detected, and the thread pool
  112. settings are automatically set based on it. Sometimes, the number of processors
  113. are wrongly detected, in such cases, the number of processors can be
  114. explicitly set using the `processors` setting.
  115. In order to check the number of processors detected, use the nodes info
  116. API with the `os` flag.