This section describes the internal message-processing model of syslog-ng, as well as
the flow-control feature that can prevent message losses. To use flow-control, the
flow-control flag must be enabled for the particular log
path.
The syslog-ng application monitors (polls) the sources defined in its configuration file, periodically checking each source for messages. When a log message is found in one of the sources, syslog-ng polls every source and reads the available messages. These messages are processed and put into the output buffer of syslog-ng (also called fifo). From the output buffer, the operating system sends the messages to the appropriate destinations.
In large-traffic environments many messages can arrive during a single poll loop,
therefore syslog-ng reads only a fixed number of messages from each source. The
log_fetch_limit() option specifies the number of messages
read during a poll loop from a single source.
![]() |
Note |
|---|---|
The |
Every destination has its own output buffer. The output buffer is needed because the
destination might not be able to accept all messages immediately. The
log_fifo_size() parameter sets the size of the output buffer.
The output buffer must be larger than the log_fetch_limit() of
the sources, to ensure that every message read during the poll loop fits into the output
buffer. If the log path sends messages to a destination from multiple sources, the
output buffer must be large enough to store the incoming messages of every source.
TCP and unix-stream sources can receive the logs from several incoming connections
(e.g., many different clients or applications). For such sources, syslog-ng reads
messages from every connection, thus the log_fetch_limit()
parameter applies individually to every connection of the source.
The flow-control of syslog-ng introduces a control window to the source that tracks
how many messages can syslog-ng accept from the source. Every message that syslog-ng
reads from the source lowers the window size by one; every message that syslog-ng
successfully sends from the output buffer increases the window size by one. If the
window is full (i.e., its size decreases to zero), syslog-ng stops reading messages from
the source. The initial size of the control window is by default
100: the log_fifo_size() must be larger
than this value in order for flow-control to have any effect. If a source accepts
messages from multiple connections, all messages use the same control window.
When flow-control is used, every source has its own control window. As a worst-case
situation, the output buffer of the destination must be set to accommodate all messages
of every control window, that is, the log_fifo_size() of the
destination must be greater than
number_of_sources*log_iw_size(). This
applies to every source that sends logs to the particular destination, thus if two
sources having several connections and heavy traffic send logs to the same destination,
the control window of every connection of both sources must fit into the output buffer
of the destination. Otherwise, syslog-ng does not activate the flow-control, and
messages may be lost.
The summary of the main points is as follows:
The syslog-ng application normally reads a maximum of
log_fetch_limit() number of messages from a
source.
From TCP and unix-stream sources, syslog-ng reads a maximum of
log_fetch_limit() from every connection of the
source. The number of connections to the source is set using the
max_connections() parameter.
Every destination has an output buffer
(log_fifo_size()).
Flow-control uses a control window to determine if there is free space in the
output buffer for new messages. Every source has its own control window;
log_iw_size() parameter sets the size of the control
window.
When a source accepts multiple connections, the messages of every connection use the same control window.
The output buffer must be larger than the control window of every connection that logs to the destination.
If the control window is full, syslog-ng stops reading messages from the source until some messages are successfully sent to the destination.
If the output buffer becomes full, and neither disk-buffering nor flow-control is used, messages may be lost.
![]() |
Note |
|---|---|
If you modify the |
See also Section 8.1, “Handling lots of parallel connections”.
Using flow-control on a source has an important side-effect if the messages of the source are sent to multiple destinations. If flow-control is in use and one of the destinations cannot accept the messages, the other destinations do not receive any messages either, because syslog-ng stops reading the source. For example, if messages from a source are sent to a remote server and also stored locally in a file, and the network connection to the server becomes unavailable, neither the remote server nor the local file will receive any messages. This side-effect of the flow-control can be avoided by using the disk-based buffering feature of syslog-ng Premium Edition.
![]() |
Note |
|---|---|
Creating separate log paths for the destinations that use the same flow-controlled source does not avoid the problem. |
© 2007-2008 BalaBit IT Security
Please send your comments or documentation bugs to: documentation@balabit.com