:_mod-docs-content-type: ASSEMBLY
include::_attributes/common-attributes.adoc[]
include::_attributes/attributes-openshift-dedicated.adoc[]
[id="logging-flow-control-mechanisms"]
= Flow control mechanisms
:context: logging-flow-control-mechanisms

toc::[]

If logs are produced faster than they can be collected, it can be difficult to predict or control the volume of logs being sent to an output.
Not being able to predict or control the volume of logs being sent to an output can result in logs being lost. If there is a system outage and log buffers are accumulated without user control, this can also cause long recovery times and high latency when the connection is restored.

As an administrator, you can limit logging rates by configuring flow control mechanisms for your {logging}.

[id="logging-configuring-flow-control-benefits"]
== Benefits of flow control mechanisms

* The cost and volume of logging can be predicted more accurately in advance.
* Noisy containers cannot produce unbounded log traffic that drowns out other containers.
* Ignoring low-value logs reduces the load on the logging infrastructure.
* High-value logs can be preferred over low-value logs by assigning higher rate limits.

[id="logging-configuring-flow-control-about-rate-limits"]
== Configuring rate limits

Rate limits are configured per collector, which means that the maximum rate of log collection is the number of collector instances multiplied by the rate limit.

Because logs are collected from each node's file system, a collector is deployed on each cluster node. For example, in a 3-node cluster, with a maximum rate limit of 10 records per second per collector, the maximum rate of log collection is 30 records per second.

Because the exact byte size of a record as written to an output can vary due to transformations, different encodings, or other factors, rate limits are set in number of records instead of bytes.

You can configure rate limits in the `ClusterLogForwarder` custom resource (CR) in two ways:

Output rate limit:: Limit the rate of outbound logs to selected outputs, for example, to match the network or storage capacity of an output. The output rate limit controls the aggregated per-output rate.

Input rate limit:: Limit the per-container rate of log collection for selected containers.

include::modules/logging-set-output-rate-limit.adoc[leveloffset=+1]

[role="_additional-resources"]
.Additional resources
* xref:../../../observability/logging/log_collection_forwarding/logging-output-types.adoc#logging-output-types[Log output types]

include::modules/logging-set-input-rate-limit.adoc[leveloffset=+1]
