On Fri, Jun 8, 2018 at 10:15 PM, Mike Torra <[email protected]> wrote:
> Hi - > > I am relatively new to using haproxy, and I am trying to figure out if it > is possible to use a consistent hashing algorithm to hash a cookie value in > to a separate header. This seems very similar to how you would use a > consistent `hash-type` (http://cbonte.github.io/haproxy-dconv/1.8/ > configuration.html#4-hash-type) for load balancing, but I don't see how > you could put the output of that hashing in to a header for backend servers > to see. > > My use case is that I have a 'uuid' cookie which I want to use to assign > users to a pool 0-100 to use in A/B (/C/D... etc) tests. Today we do this > in a nodejs app, but we are adding new backends and we want to avoid > implementing the same hashing in multiple languages. > > I'm currently using haproxy 1.8. I appreciate any suggestions! > > - Mike > Hi Mike, Your goal is not really clear to me. I think you would like to see the output of the hash performed by HAProxy on this UUID cookie in a HTTP header. Depending on your hash-type algorithm, you may wan to use the corresponding converter: backend b_myapp [...] balance hdr(X-Cook-Uuid) hash-type consistent sdbm http-request set-header X-Cook-Uuid %[req.cook(UUID)] http-request set-header X-Cook-Uuid-Hashed %[req.hdr(X-Cook-Uuid),sdbm] Simply adjust hash-type algorithm to the right converter name. More on converter: http://cbonte.github.io/haproxy-dconv/1.8/configuration.html#7.3.1-sdbm Baptiste

