[MEDIUM] session counters: add conn_rate and sess_rate counters
authorWilly Tarreau <w@1wt.eu>
Sun, 20 Jun 2010 09:19:22 +0000 (11:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 10 Aug 2010 16:04:13 +0000 (18:04 +0200)
commit91c43d7fe4e5a33c87a9dd82a52156e4daac9b81
treef4ddc1a7db5945ce4197efd4bbdec9ef8cebaf0b
parentac78288eaf9601351731b187dfc006648546d3b8
[MEDIUM] session counters: add conn_rate and sess_rate counters

These counters maintain incoming connection rates and session rates
in a stick-table, over a period which is defined in the configuration
(2 ms to 24 days). They can be used to detect service abuse and
enforce a certain accept rate per source address for instance, and
block if the rate is passed over.

Example :
# block if more than 50 requests per 5 seconds from a source.
stick-table type ip size 200k expire 1m store conn_rate(5s),sess_rate(5s)
tcp-request track-counters src
tcp-request reject if { trk_conn_rate gt 50 }

# cause a 3 seconds pause to requests from sources in excess of 20 requests/5s
tcp-request inspect-delay 3s
tcp-request content accept if { trk_sess_rate gt 20 } WAIT_END
include/proto/session.h
include/types/stick_table.h
src/session.c
src/stick_table.c