|
| 1 | +--- |
| 2 | +description: Learn how to run Fluent Bit in multiple threads for improved scalability. |
| 3 | +--- |
| 4 | + |
| 5 | +# Multithreading |
| 6 | + |
| 7 | +Fluent Bit has one event loop to handle critical operations, like managing |
| 8 | +timers, receiving internal messages, scheduling flushes, and handling retries. |
| 9 | +This event loop runs in Fluent Bit's main thread. |
| 10 | + |
| 11 | +To free up resources in the main thread, you can configure |
| 12 | +[inputs](../pipeline/inputs/README.md) and [outputs](../pipeline/outputs/README.md) |
| 13 | +to run in their own self-contained threads. However, inputs and outputs implement |
| 14 | +multithreading in distinct ways: inputs can run in **threaded** mode, and outputs |
| 15 | +can use one or more **workers**. |
| 16 | + |
| 17 | +Threading also affects certain processes related to inputs and outputs. For example, |
| 18 | +[filters](../pipeline/filters/README.md) always run in the main thread, but |
| 19 | +[processors](../pipeline/processors/README.md) run in the self-contained threads of |
| 20 | +their respective inputs or outputs, if applicable. |
| 21 | + |
| 22 | +## Inputs |
| 23 | + |
| 24 | +When inputs collect telemetry data, they can either perform this process |
| 25 | +inside Fluent Bit's main thread or inside a separate dedicated thread. You can |
| 26 | +configure this behavior by enabling or disabling the `threaded` setting. |
| 27 | + |
| 28 | +All inputs are capable of running in threaded mode, but certain inputs always |
| 29 | +run in threaded mode regardless of configuration. These always-threaded inputs are: |
| 30 | + |
| 31 | +- [Kubernetes Events](../pipeline/inputs/kubernetes-events.md) |
| 32 | +- [Node Exporter Metrics](../pipeline/inputs/node-exporter-metrics.md) |
| 33 | +- [Process Exporter Metrics](../pipeline/inputs/process-exporter-metrics.md) |
| 34 | +- [Windows Exporter Metrics](../pipeline/inputs/windows-exporter-metrics.md) |
| 35 | + |
| 36 | +Inputs are not internally aware of multithreading. If an input runs in threaded |
| 37 | +mode, Fluent Bit manages the logistics of that input's thread. |
| 38 | + |
| 39 | +## Outputs |
| 40 | + |
| 41 | +When outputs flush data, they can either perform this operation inside Fluent Bit's |
| 42 | +main thread or inside a separate dedicated thread called a _worker_. Each output |
| 43 | +can have one or more workers running in parallel, and each worker can handle multiple |
| 44 | +concurrent flushes. You can configure this behavior by changing the value of the |
| 45 | +`workers` setting. |
| 46 | + |
| 47 | +All outputs are capable of running in multiple workers, and each output has |
| 48 | +a default value of `0`, `1`, or `2` workers. However, even if an output uses |
| 49 | +workers by default, you can safely reduce the number of workers below the default |
| 50 | +or disable workers entirely. |
0 commit comments