# Multithreading

Fluent Bit has one event loop to handle critical operations, like managing timers, receiving internal messages, scheduling flushes, and handling retries. This event loop runs in the main Fluent Bit thread.

To free up resources in the main thread, you can configure [inputs](https://docs.fluentbit.io/manual/data-pipeline/inputs) and [outputs](https://docs.fluentbit.io/manual/data-pipeline/outputs) to run in their own self-contained threads. However, inputs and outputs implement multithreading in distinct ways: inputs can run in `threaded` mode, and outputs can use one or more `workers`.

Threading also affects certain processes related to inputs and outputs. For example, [filters](https://docs.fluentbit.io/manual/data-pipeline/filters) always run in the main thread, but [processors](https://docs.fluentbit.io/manual/data-pipeline/processors) run in the self-contained threads of their respective inputs or outputs, if applicable.

## Inputs

When inputs collect telemetry data, they can either perform this process inside the main Fluent Bit thread or inside a separate dedicated thread. You can configure this behavior by enabling or disabling the `threaded` setting.

All inputs are capable of running in threaded mode, but certain inputs always run in threaded mode regardless of configuration. These always-threaded inputs are:

* [Kubernetes Events](https://docs.fluentbit.io/manual/data-pipeline/inputs/kubernetes-events)
* [Node Exporter Metrics](https://docs.fluentbit.io/manual/data-pipeline/inputs/node-exporter-metrics)
* [Process Exporter Metrics](https://docs.fluentbit.io/manual/data-pipeline/inputs/process-exporter-metrics)
* [Windows Exporter Metrics](https://docs.fluentbit.io/manual/data-pipeline/inputs/windows-exporter-metrics)

Inputs aren't internally aware of multithreading. If an input runs in threaded mode, Fluent Bit manages the logistics of that input's thread.

## Outputs

When outputs flush data, they can either perform this operation inside the main Fluent Bit thread or inside a separate dedicated thread called a *worker*. Each output can have one or more workers running in parallel, and each worker can handle multiple concurrent flushes. You can configure this behavior by changing the value of the `workers` setting.

All outputs are capable of running in multiple workers, and each output has a default value of `0`, `1`, or `2` workers. However, even if an output uses workers by default, you can safely reduce the number of workers under the default or disable workers entirely.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fluentbit.io/manual/administration/multithreading.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
