On Sun, 4 Dec 2016 09:17:00 -0500
Patrick Hemmer <[email protected]> wrote:

> I was mostly just wondering about differences between using things like
> `capture request header`/`http-request capture` and `http-request set-var`.
> 
> set-var seems to have all the capabilities of captures, and are much
> easier to work with. You don't have to pre-declare them, you don't have
> to set their size, you don't have to remember the order in which you
> declared them and reference them by an index.
> 
> So what's the benefit of captures? Are they more performant or something?


Hi Patrick,

This is a good question !

Capture header are faster. It uses memory pool of predefined size and
the access to a captures header is fast because it is indexed with an
integer.

set-var uses the standard system memory allocation and a memory
accounting system for preventing a large amount of consomation. This
memory allocation system is slow. In other way, each is stored in a
list and HAProxy must browse this list for each var access.

So, you're right: capture header is more performant. set-var is more
easy to use.

Note that the var cotaining ip or integer doesn't use the system memory
allocator.

Finally, I realize a quick benchmark on my computer. I capture the
header user-agent containing 127 bytes (and configured for capturing
128) with the two methods.

   set-var : 90262 req/s
   capture : 92257 req/s

So, on my computer, "set-var" is 2% slowly than "capture".

Thierry


Reply via email to