A/B Testing with haproxy

April 2, 2025

Table of Contents

listen http-inbind x.x.x.x:80option httplogbalance sourceuse-server old if { req.cook(SITEID) -m beg old_site_90 }use-server new if { req.cook(SITEID) -m beg new_site_10 }server old 127.0.0.1:8080 weight 90server new 127.0.0.1:8081 weight 10default_backend old listen old bind 127.0.0.1:8080 mode http option httplog balance roundrobin cookie SITEID insert indirect nocache maxlife 48h server web01 x.x.x.x:80 check inter 1000 maxconn 125 cookie old_site_90 appsession SESS len 50 timeout 3h request-learn prefix option http-server-close option httpclose option forwardfor listen new bind 127.0.0.1:8081 mode http option httplog balance roundrobin cookie SITEID insert indirect nocache maxlife 48h server web02 x.x.x.x:80 check inter 1000 maxconn 125 cookie new_site_10 appsession SESS len 50 timeout 3h request-learn prefix option http-server-close option httpclose option forwardfor Now this is all fine for cookies which are already set but the initial seeding needs to be done to take care of the 90:10 split. This can be done by having multiple servers on "old" backend and one of them sending out the "SITEID" as "new_site_10". This will seed a small proportion of users onto the new backend. Setup Details Centos 6.6 haproxy-1.5.5-1.el6.x86_64]]>Check the pricing of our offerings here

Latest Blogs

A vector illustration of a tech city using latest cloud technologies & infrastructure