HAProxy Enterprise Documentation 2.3r1

Overview

A stick table tracks counters (also known as data types) that count certain events so that you can observe behavior over time. For example, you could count the number of times a user has made a request. Stick tables have a predefined list of these counters, which cover tasks such as calculating a client's request rate.

For each stick-table directive that you add to your configuration file, HAProxy Enterprise provisions a new storage area, which is similar to a table in a relational database where each table holds its own set of records.

Entries in a stick table are useful for various purposes, such as:

  • counting the number of requests a client makes.

  • counting errors a particular client has triggered.

  • counting the number of times a webpage has been accessed.

With this data, you can enforce policies such as setting rate limits on clients who make too many requests.

The structure of a stick table with three records looks like this:

key

counter 1

counter 2

expires

192.168.0.10

10

1

1 minute

192.168.0.18

11

3

45 seconds

192.168.0.23

9

2

5 seconds

In this case, we are tracking two counters and the key that we use to keep track of them is the client's IP address. In this generic example, I have labelled the counters counter 1 and counter 2. In reality, counters have specific names like conn_rate and sess_cnt.

A record has an expiration time. When a record expires, it is removed, unless it's accessed again within that time. You define the expiration time when you define the stick table.


Next up

Syntax