Return to
Portfolio

25.13. Rate Limiting

The poor man’s tool for rate limiting is the sleep() procedure.

Example 112. Rate Limiting with sleep()

In the following example sleep() is invoked with 500 microseconds. This means that the input module will be able to read at most 2000 messages per second.

nxlog.conf [Download file]
1
2
3
4
5
6
<Input in>
    Module  im_tcp
    Host    0.0.0.0
    Port    1514
    Exec    sleep(500);
</Input>

This is not very precise because the module can do additional processing which can add some to the total execution time, but it gets fairly close.

Warning
It is not recommended to use rate limiting on a route that reads logs over UDP.