Live data from Hacker News

True Zero-Downtime HAProxy Reloads

engineeringblog.yelp.com

31–40 of 54 posts

Re: True Zero-Downtime HAProxy Reloads

#31
Everyone seems to have overlooked the fact this only works for outgoing traffic, you can't use this strategy on a public facing load-balancer without additional work.

Specifically you will need to accept the traffic on one interface and forward to a new local interface in order to apply the qdisc plug.

This is cool, but the above is still a pain in the neck.

Re: True Zero-Downtime HAProxy Reloads

#32

When you run `/etc/init.d/nginx reload` I was under this impression this is zero-downtime. Is that not true then?

If you truly meant Nginx and not HAProxy, Nginx does its best to avoid dropping connections on a reload:

http://nginx.org/en/docs/control.html

> In order for nginx to re-read the configuration file, a HUP signal should be sent to the master process. The master process first checks the syntax validity, then tries to apply new configuration, that is, to open log files and new listen sockets. If this fails, it rolls back changes and continues to work with old configuration. If this succeeds, it starts new worker processes, and sends messages to old worker processes requesting them to shut down gracefully. Old worker processes close listen sockets and continue to service old clients. After all clients are serviced, old worker processes are shut down.

It brings up the new worker processes to handle new connections and wait for the existing connections to terminate. Key phrase is "does its best", I've seen edge cases that aren't really Nginx's fault that cause connections to be dropped. [e.g. OOM issues when it tries to bring up new workers]

Re: True Zero-Downtime HAProxy Reloads

#33
post #24

My gut feeling is that this approach can be prone to silent misbehavior that they cannot detect. There's no reason not to patch HA to reload it's config and reapply it.

We're using this for internal load balancing, so we control both ends of the connection. If this started misbehaving, we'd see timeouts, dropped connections, or errors, which would show up in logs.

Re: True Zero-Downtime HAProxy Reloads

#34

My favorite part was when you were rewarded for scouring the source code by finding an undocumented qdisc, that was golden. :) You mentioned that your colleague had produced a patch that did file handle passing? Is that patch available? My first thought on reading that was, how many other people have tried that very task. Im wondering if it would be helpful to HAPrpxy if your patch was made available? Thank you for s…

Yep, I found a number of them, but I promptly forgot them in excitement when I found the one I actually wanted. If you want to check them out yourself, they appear to congregate in the kernel tree at net/sched/sch_* [1].

The only other qdisc I have much experience with is sch_netem, which emulates behaviors of a WAN (delay, loss, etc). I used it in this post [2] to conduct adversarial testing of MySQL replication (search 'tc qdisc').

[1] http://lxr.free-electrons.com/source/net/sched/

[2] http://engineeringblog.yelp.com/2014/03/mysql-replication-ne...

Re: True Zero-Downtime HAProxy Reloads

#35
Why not simply let DNS handle the routing and load balancing?

Bring up another HAProxy with the new configuration. Then swap the new and old IP addresses in DNS. Wait for DNS to propagate. When traffic on old HAProxy is zero, bring it down.

Re: True Zero-Downtime HAProxy Reloads

#36

Earlier quoted context omitted.

Another approach: have haproxy fork/exec a child, inheriting the same file descriptor for the listening socket, then have the child tell the parent when it should stop accepting connections on that socket. No idea how that works in practice, but it seems like a sound concept? :)

Yes, that's how Unicorn works. But HAProxy isn't designed to inherit another process's current state (see this other comment: https://news.ycombinator.com/item?id=9371064 ), and it's probably quite complicated and error-prone. If you're going down that route, it's probably much easier to write the code required to simply re-read the config and apply a diff to the internal data structures.

[deleted]

Re: True Zero-Downtime HAProxy Reloads

#37
post #35

Why not simply let DNS handle the routing and load balancing? Bring up another HAProxy with the new configuration. Then swap the new and old IP addresses in DNS. Wait for DNS to propagate. When traffic on old HAProxy is zero, bring it down.

DNS is a fragile system to use within a DC to do service/endpoint discovery. That's because DNS tends to be a single point of failure.

Though the DNS system can inherently be resilient, within a DC most people only operate a single DNS server because a hierarchical domain scheme and DNS setup within DC is too cumbersome and is much less reactive to end point changes. Eg: Changing a service endpoint in an emergency takes way too long.

A single DNS server means, still there are propagation delays(local caches) and a single point of failure at critical moments(when there is a thundering herd)

Re: True Zero-Downtime HAProxy Reloads

#38
post #35

Why not simply let DNS handle the routing and load balancing? Bring up another HAProxy with the new configuration. Then swap the new and old IP addresses in DNS. Wait for DNS to propagate. When traffic on old HAProxy is zero, bring it down.

DNS is surprisingly tricky as a service discovery tool. A lot of clients are poorly behaved, and will cache values for too long (or forever). It'd also be another dependency critical for site functionality.

Re: True Zero-Downtime HAProxy Reloads

#39
post #24

My gut feeling is that this approach can be prone to silent misbehavior that they cannot detect. There's no reason not to patch HA to reload it's config and reapply it.

We're using this for internal load balancing, so we control both ends of the connection. If this started misbehaving, we'd see timeouts, dropped connections, or errors, which would show up in logs.

I see. Any reason not to patch HA to reload config?

Re: True Zero-Downtime HAProxy Reloads

#40
post #29
post #25

Earlier quoted context omitted.

That's an important detail, as it explains why the tests aren't entirely flawed: Testing 10 reloads every second really distorts the numbers, assuming a reload every hour, or every few hours is more realistic. But if reloads are part of what amounts to doing live testing on a large part of live traffic -- then the exercise makes more sense. And to be sure; being able to do ten reloads every second with few ill effect…

> Testing 10 reloads every second really distorts the numbers, assuming a reload every hour, or every few hours is more realistic. It depends on what you do. I've seen shops (successfully and, IMO, correctly) scaling AWS instances for services with a threshhold of every fifteen minutes, and I've seen Mesos clusters dynamically spinning up web instances much more nimbly than that (think every two minutes under spiky l…

Well, once every 120 seconds is still quite a leap from 10 every second...
Post reply on HN