|
| 1 | +.. _buffering: |
| 2 | + |
| 3 | +===================== |
| 4 | +Configuring Buffering |
| 5 | +===================== |
| 6 | + |
| 7 | +All filter and output plugins support the use of a disk based message queue. |
| 8 | +If ``use_buffering`` is set to true, then the router will deliver messages that |
| 9 | +match the plugin's :ref:`message matcher <message_matcher>` to the queue |
| 10 | +buffer, and the plugin will read from the queue to get messages to process, |
| 11 | +instead of the handoff happening in the process RAM via Go channels. This |
| 12 | +improves message delivery reliability and allows plugins to reprocess messages |
| 13 | +from the queue in cases where upstream servers are down or Heka is recovering |
| 14 | +from a hard shutdown. |
| 15 | + |
| 16 | +Each queue buffer supports a few configuration settings in addition to any |
| 17 | +options which the plugin might support. These can be specified in a sub-section |
| 18 | +of the plugin's TOML configuration section entitled ``buffering``. |
| 19 | + |
| 20 | +Buffering configuration settings |
| 21 | +================================ |
| 22 | + |
| 23 | +- max_file_size (uint64) |
| 24 | + The maximum size (in bytes) of a single file in the queue buffer. When a |
| 25 | + message would increase a queue file to greater than this size, the message |
| 26 | + will be written into a new file instead. Defaults to 128MiB. Value cannot |
| 27 | + be zero, if zero is specified the default will instead be used. |
| 28 | + |
| 29 | +- max_buffer_size (uint64) |
| 30 | + Maximum amount of disk space (in bytes) that the entire queue buffer can |
| 31 | + consume. Defaults to 0, or no limit. The action taken when the maximum buffer |
| 32 | + size is reached is determined by the ``full_action`` setting. |
| 33 | + |
| 34 | +- full_action (string) |
| 35 | + The action Heka will take if the queue buffer grows to larger than the |
| 36 | + maximum specified by the ``max_buffer_size`` setting. Must be one of the |
| 37 | + following values. Defaults to ``shutdown``, although specific plugins might |
| 38 | + override this default with a default of their own: |
| 39 | + |
| 40 | + * ``shutdown``: Heka will stop all processing and attempt a clean shutdown. |
| 41 | + |
| 42 | + * ``drop``: Heka will drop the current message and will continue to process |
| 43 | + future messages. |
| 44 | + |
| 45 | + * ``block``: Heka will pause message delivery, applying back pressure through |
| 46 | + the router to the inputs. Delivery will resume if and when the |
| 47 | + queue buffer size reduces to below the specified maximum. |
| 48 | + |
| 49 | +- cursor_update_count (uint) |
| 50 | + A plugin is responsible for notifying the queue buffer when a message has |
| 51 | + been processed by calling an ``UpdateCursor`` method on the |
| 52 | + PluginRunner. Some plugins call this for every message, while others call it |
| 53 | + only periodically after processing a large batch of messages. This setting |
| 54 | + specifies how many ``UpdateCursor`` calls must be made before the cursor |
| 55 | + location is flushed to disk. Defaults to 1, although specific plugins might |
| 56 | + override this default with a default of their own. Value cannot be zero, if |
| 57 | + zero is specified the default will be used instead. |
| 58 | + |
| 59 | +Buffering Default Values |
| 60 | +======================== |
| 61 | + |
| 62 | +Please note that if you provide a `buffering` subsection for your plugin |
| 63 | +configuration, it is best to specify *all* of the available settings. In cases |
| 64 | +where the plugin specifies a non-standard default for one or more of these |
| 65 | +values, that default will only be applied if you omit the `buffering` |
| 66 | +subsection altogether. If you specify any of the values, it is expected that |
| 67 | +you will specify all of the values. |
| 68 | + |
| 69 | +Sample Buffering Configuration |
| 70 | +============================== |
| 71 | + |
| 72 | +The following is a sample TcpOutput configuration showing the use of buffering. |
| 73 | + |
| 74 | +.. code-block:: ini |
| 75 | +
|
| 76 | + [TcpOutput] |
| 77 | + message_matcher = "Type !~ /^heka/" |
| 78 | + address = "upstream.example.com:5565" |
| 79 | + keep_alive = true |
| 80 | + use_buffering = true |
| 81 | +
|
| 82 | + [TcpOutput.buffering] |
| 83 | + max_file_size = 268435456 # 256MiB |
| 84 | + max_buffer_size = 1073741824 # 1GiB |
| 85 | + full_action = "block" |
| 86 | + cursor_update_count = 100 |
0 commit comments