Perlbal::Plugin::Throttle(3pm) User Contributed Perl Documentation Perlbal::Plugin::Throttle(3pm)

Perlbal::Plugin::Throttle - Perlbal plugin that throttles connections from hosts that connect too frequently.

    # in perlbal.conf
    LOAD Throttle
    CREATE POOL web
        POOL web ADD 10.0.0.1:80
    CREATE SERVICE throttler
        SET role                        = reverse_proxy
        SET listen                      = 0.0.0.0:80
        SET pool                        = web
        # adjust throttler aggressiveness
        SET initial_delay               = 10
        SET max_delay                   = 60
        SET throttle_threshold_seconds  = 3
        SET max_concurrent              = 2
        SET ban_threshold               = 4
        SET ban_expiration              = 180
        # limit which requests are throttled
        SET path_regex                  = ^/webapp/
        SET method_regex                = ^GET$
        # allow or ban specific addresses or range (requires Net::CIDR::Lite)
        SET whitelist_file              = conf/whitelist.txt
        SET blacklist_file              = conf/blacklist.txt
        # granular logging (requires Perlbal::Plugin::Syslogger)
        SET log_events                  = ban,unban,throttled,banned
        SET log_only                    = false
        # share state between perlbals (requires Cache::Memcached::Async)
        SET memcached_servers           = 10.0.2.1:11211,10.0.2.2:11211
        SET memcached_async_clients     = 4
        SET instance_name               = mywebapp
        SET plugins                     = Throttle
    ENABLE throttler

This plugin intercepts HTTP requests to a Perlbal service and slows or drops connections from IP addresses which are determined to be connecting too fast.

An IP address address may be in one of four states depending on its recent activity; that state determines how new requests from the IP are handled:

  • ban

    Log when a temporary local ban is added for an IP address.

  • unban

    Log when a temporary local ban is removed for an IP address.

  • whitelisted

    Log when a request is allowed because the source IP is on the whitelist.

  • blacklisted

    Log when a request is denied or throttled because the source IP is on the blacklist.

  • banned

    Log when a request is denied because the source IP is on the temporary ban list for connecting excessively.

  • concurrent

    Log when a request is denied because the source IP has too many open connections waiting to be unthrottled.

  • throttled

    Log when a request is throttled because the source IP was not on the whitelist or blacklist.

  • all

    Enables all the above logging options.

  • none

    Disables all the above logging options.

List of tunables in Throttle.pm.

Fix white/blacklist loading

Load CIDR lists asynchronously (perhaps in the manner of Perlbal::Pool::_load_nodefile_async).

Adam Thomason, <athomason@cpan.org>

Copyright (C) 2007-2011 by Say Media Inc, <cpan@sixapart.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

2022-06-28 perl v5.34.0