Using HAProxy to load-balance multiple web servers
Once upon a time a load balancer was a big box that sat in a rack and cost eighty thousand dollars. Although you can still buy those, for most organizations a software load balancer solution using commodity Linux servers is a better value proposition.
HAProxy is the software load balancer of choice for most people: fast, powerful, and highly configurable.
How to do it…
In this recipe, I'll show you how to build an HAProxy server to load-balance web requests across two existing backend servers.
Run the following commands:
ubuntu@cookbook:~/puppet$ mkdir -p modules/haproxy/manifests ubuntu@cookbook:~/puppet$ mkdir -p modules/haproxy/files
Create the file
modules/haproxy/manifests/init.pp
with the following contents:# Manage HAProxy class haproxy { package { 'haproxy': ensure => installed } file { '/etc/default/haproxy': content => "ENABLED=1\n", require => Package['haproxy'], } service { 'haproxy': ensure =>...