Messaging Patterns: Throttling

Only keep one event per time unit from a high frequency stream.

By Mathias Verraes
Published on 23 May 2019



Throttling

Only keep one event per time unit from a high frequency stream.

Problem

A stream of Ephemeral Events is too much to handle for a consumer.

Solution

An intermediary consumer is placed in front of the original consumer. It drops all events, except once per time unit, where it passes the event to the original consumer.

Example

This pattern is very common in user interfaces. An input device, such as a mouse, emits it’s position at 500 Hz. Instead of rendering at the same frequency, the stream is throttled at 5Hz, and therefore the consumer only needs to rerender 5 times per second.