New job assessment: Redundant load balancer design

These is one of the proposed solutions for the job assessment commented in a previous post.

Using an Open Source solution, design a load balancer configuration that meets: redundancy, multiples subnets, and handle 500-1000Mbit of syn/ack/fin packets. Explain scalability of your design/configs.

The main problem that the load balancer design must solve in web applications is the session stickiness (or persistence). The load balancer design must be created according to the session replication policy of the architecture. On the other hand, the load balancer must be designed to allow the upgrade and maintenance of the servers.

Considering the architecture explained in Webserver architecture section, the stickiness restrictions are:

The software that I propose is HAProxy (

The load balancer design consists of two layers:

Extra comments:

This solution scales well. You simply need to add more servers, farms and sites. Load-balancers can scale horizontally as commented.

Primary configuration:

[sourcecode launguage="bash"]

Primary Load Balancer configuration: primary-haproxy.conf

global log local0 log local1 notice #log loghost local0 info maxconn 40000 user haproxy group haproxy daemon #debug #quiet

defaults log global mode http option httplog option dontlognull retries 3 option redispatch maxconn 2000 contimeout 5000 clitimeout 50000 srvtimeout 50000

listen primarylb1 # We insert cookies, add headers => http mode mode http

# Bind to all address.
# Bind to a clusterized virtual ip
bind transparent

# Cookie persistence for PHP sessions. Options
#  - rewrite PHPSESSID: will add the server label to the session id
#cookie PHPSESSID rewrite indirect
#  - insert a cookie with the identifier.
#    Use of postonly (session created in login form) or nocache to avoid be cached
cookie SITEID insert postonly

# We need to know the client ip in the end servers.
# Inserts X-Forwarded-For. Needs httpclose (no Keep-Alive).
option forwardfor
option httpclose

# Roundrobin is ok for HTTP requests.
balance roundrobin

# The backend sites
# Several options are possible:
#  inter 2000 downinter 500 rise 2 fall 5 weight 100
server site1 cookie site1 check
server site2 cookie site2 check
# etc..


Site configuration:

[sourcecode launguage="bash"]

Site 1 load balancer configuration: syte1-haproxy.conf

global log    local0 log    local1 notice

log loghost    local0 info

maxconn 40000 user haproxy group haproxy daemon



defaults log    global mode    http option    httplog option    dontlognull retries    3 option redispatch maxconn    2000 contimeout    5000 clitimeout    50000 srvtimeout    50000


listen site1lb1 grace 20000 # don't kill us until 20 seconds have elapsed

Bind to all address.


Bind to a clusterized virtual ip

bind transparent


The webservers in same farm share the session

with memcached. The whole site has them in a DB backend.

mode http cookie FARMID insert postonly

Roundrobin is ok for HTTP requests.

balance roundrobin

Farm 1 servers

server site1ws1 cookie farm1 check server site1ws2 cookie farm1 check


Farm 2 servers

server site1ws17 cookie farm2 check server site1ws18 cookie farm2 check server site1ws19 cookie farm1 check