Multi Process Workers
Last updated
Last updated
This article describes how to use Fluentd's multi-process workers feature for high traffic. This feature launches two or more fluentd workers to utilize multiple CPU powers.
This feature can simply replace fluent-plugin-multiprocess
.
By default, one instance of fluentd
launches a supervisor and a worker. A worker consists of input/filter/output plugins.
The multi-process workers feature launches multiple workers and use a separate process per worker. fluentd
provides several features for multi-process workers.
workers
Parameter<system>
directive has workers
parameter for specifying the number of workers:
With this configuration, fluentd launches four (4) workers.
<worker>
directiveSome plugins do not work with multi-process workers feature automatically, e.g. in_tail
. However, these plugins can be configured to run on specific workers with <worker N>
directive. N
is a zero-based worker index.
In the following example, the in_tail
plugin will run only on worker 0 out of the 4 workers configured in the <system>
directive:
With <worker>
directive, non-multi-process-ready plugins can seamlessly be run along with multi-process-ready plugins.
<worker N-M>
directiveAs of Fluentd v1.4.0, <worker N-M>
syntax has been introduced:
With this directive, you can specify multiple workers per worker directive.
Each worker consumes memory and disk space separately. Take care while configuring buffer spaces and monitoring memory/disk consumption.
There are three (3) types of input plugins:
feature supported and server helper based plugin
feature supported and plain plugin
feature unsupported
Server plugin helper based plugin can share port between workers. For example, forward
input plugin does not need multiple ports on multi process workers. forward
input's port is shared among workers.
Non-server plugin helper based plugin set up socket/server in each worker. For example, monitor_agent
needs multiple ports on multi-process workers. The port is assigned sequentially.
Some plugins do not work on multi-process workers. For example, tail
input does not work because in_tail
cannot be implemented with multi process.
You can run these plugins with <worker N>
directive. See "Configuration" section.
By default, no additional changes are required but some plugins do need to specify the worker_id
in the configuration. For example, file
and S3
plugins store events into a specified path. The problem is if the plugins under multi-process workers flush events at the same time, the destination path is also the same which results in data loss. To avoid this problem, a worker_id
or some random string can be configured.
See Configuration File article for embedded Ruby code feature.
You may see following error in the fluentd logs:
This means that the configured plugin does not support multi-process workers. All configured plugins must support multi-process workers. See "Multi-Process Worker and Plugins" section above.
If this article is incorrect or outdated, or omits critical information, please let us know. Fluentd is an open-source project under Cloud Native Computing Foundation (CNCF). All components are available under the Apache 2 License.