
Getting the most out of HAProxy - kevinburke
https://www.twilio.com/engineering/2013/10/16/haproxy
======
falcolas
Want to know what else is cool about haproxy? The stats unix socket. With it,
you can query the existing configuration at whim, and with haproxy 1.4 or
greater, you can configure haproxy on the fly.

    
    
        show stat -1 4\n
        disable server xyz\n
    

What's not so cool? Disabling a server does nothing to kill off existing
connections to that server, and idle timeouts can cause problems if your
processes are slow to respond.

With care, though, it's a great component of a HA solution, in addition to a
being a great load balancer.

~~~
nasalgoat
If you're running multiple haproxy processes, the unix socket commands only
work on the process you happen to randomly get when you use the socket.

I've asked about plans to fix that and it's not on the current roadmap for
1.5.

I need multiple processes to allow SSL offloading.

~~~
falcolas
Perhaps start each up with a separate configuration file for each instance? Or
run as a cluster, so changes to one are propagated to all (untested)?

    
    
        haproxy -f /path/to/alternate/cfg

------
nl
_As we convert more and more Twilio tools to a service-oriented architecture,
these logs have been invaluable at debugging failures_

I'd love to know more about how Twilio does SOA (and no, the linked document
doesn't expand on it).

Do they use an ESB or do they rely on individual services connecting directly
to each other?

I'm 100% convinced of the ideas behind a service-oriented architecture. I'm
less convinced about the need for an ESB, but I'm happy to be talked around.

Experiences/Opinions/War Stories eagerly sought.

~~~
kevinburke
Internally each FE runs HAProxy to round robin between all of the shared
backends, no ESB involved. Hoping to write another blog post about this soon.

Agree that the link is kind of not-good, this might help a little...
[http://www.slideshare.net/twilio/highavailability-
infrastruc...](http://www.slideshare.net/twilio/highavailability-
infrastructure-in-the-cloud-evan-cooke-web-20-expo-nyc-2011)

I wish I could say more about our infrastructure and experience with SOA, but
I'm a little limited in what I can share. We are hiring though :)

~~~
nl
Thanks for the response & link.

What's a "FE"?

~~~
llakey
I suspect it's short for: Front End

------
gopalv
More fun HAProxy bits include pinning a user persistently to one machine
(which fails over when that machine fails a health-check)

Particularly useful when you've got a web+mc combo in one machine which can
get the most out of such a setup - [http://notmysock.org/blog/hacks/haproxy-
user-repinning](http://notmysock.org/blog/hacks/haproxy-user-repinning)

------
petercooper
I don't do anything heavy enough to need load balancing, but I've always found
HAProxy to be ideal for situations where I'm limited by IPs but I want to run
a variety of HTTP oriented services on the same machine.

It's so easy to filter by hostname and send requests off to different internal
daemons and HAProxy is solid as a rock unlike other mechanisms I've tried.

------
jtokoph
Another cool HAProxy option is setting up backup/failover backends. So if all
of your real backends die or go offline, haproxy can serve a friendly
maintenance/downtime page from the failover backend.

------
zerop
where haproxy scores above ngingx..I am curious to know, as we use nginx....

~~~
zh
NginX is very good WEB SERVER - so it shines in serving content - web pages,
caching images etc. But in proxy mode, the load-balancing between backends is
pretty basic. HAProxy is born to be very good LOAD BALANCER - you can have
different balancing algorithms, not only round-robin. HAProxy have also TCP
mode, so you can balance your MySQL backends, for example. Also for me,
personally, HAProxy stats rock.

~~~
ZoFreX
Thanks for the explanation, it's very enlightening to someone (me) who's never
used haproxy. For front-end load balancing, I've been using Varnish. Is
HAProxy also better at http load balancing than Varnish as well as nginx, do
you know?

~~~
unkoman
I use both, as varnish does caching well. Two haproxy servers where one is a
fail over. varnish on both.

