jezahost
  • high-availability
  • proxmox
  • testing
  • reliability

We cut the power to a server: does HA really work?

High availability (HA) works everywhere on paper. We deliberately cut the power to one physical server and watched with a stopwatch: the virtual server came up somewhere else in 2 minutes 35 seconds. But something we did not expect happened too.

The sentence "our servers run in an HA cluster" is easy to write. There is one way to know whether it is true: cut the power to one of the physical servers and watch what happens.

It was early October, in the evening. In this post we tell what we expected, what we saw and what we changed after the test.

What HA promises

The idea is simple. Your virtual server runs on top of a physical machine. If that machine fails, the cluster sees it and restarts the virtual server on another machine. Because your disk is kept in distributed storage, no data is lost.

The hard part is in the word "sees". The cluster has to know for certain whether a machine that has gone silent is really dead or has just dropped off the network. If it gets this wrong and starts the same virtual server in two places at once, the disk gets corrupted. That is why the cluster does not hurry: first it makes sure that the silent machine is no longer writing anything. This is called fencing.

In Proxmox it works like this: a machine that loses contact with the cluster hard-powers itself off about a minute later. The remaining machines wait out this period and only then take over the virtual servers.

How we set up the test

We did not want to experiment on customers. So we moved all customer servers off the machine we were going to switch off in advance, and kept only one test virtual server on it.

The second rule: one variable per test. We also moved the cluster's management roles to another machine in advance. Otherwise, if the result had been bad, we would not have been able to tell which cause it was.

Then we hard-powered the machine off from the remote management panel. Not a tidy "shutdown", but a direct cut of the power. A real failure gives no warning.

What happened

TimeEventTime elapsed
22:12:46Last signal from the machine, power cut0
22:14:00The cluster declared the machine dead74 seconds
22:15:01The virtual server is being started on another machine135 seconds
22:15:21The virtual server is running155 seconds

2 minutes 35 seconds in total. Of that, 74 seconds is detection and waiting, and the remaining 81 seconds is making the disk available in the new place and booting the virtual server.

What else we looked at during this time:

  • The cluster did not lose its ability to make decisions even for a moment.
  • None of the customer servers on the other machines was touched.
  • Our public status page did not open an incident, because nothing visible to a customer had stopped.
  • When the machine we had switched off came back, it joined the cluster by itself, returned to its normal state by itself, and nothing was left half-done.

What we did not expect

The virtual server came up, but not on the machine best suited for it from our point of view.

It was running, but slower than before. So the customer would have got their server back, only its speed would have been lower.

The cause turned out to be simple: when HA picks the recovery location, it does not know where the server will run better, it just picks an available machine. We were the ones who should have told it that, and we had not.

The second finding was more worrying. The recovery worked only because that same day, just two hours before the test, we had made a change in the storage settings. In the state before that change the virtual server would not have come up at all. So if we had run this test a day earlier, the result would have been "HA does not work". And if we had not run it, we would have learned this in a real failure.

What we changed

The next day we added placement rules: every virtual server first comes up on the machines best suited for it. We deliberately did not make the rules strict. If none of those machines is available, the virtual server still comes up somewhere else. A slow server is better than a server that is not running.

There are two small traps here in the latest version of Proxmox. The old "HA groups" no longer exist, rules have replaced them. And a rule can only be written for a virtual server that has already been added to HA, so the order matters.

After that we put all customer servers under HA.

What we learned

2 minutes 35 seconds is not zero. HA does not mean "it never stops", it means "if a physical machine dies, it comes back by itself within a few minutes, and nobody has to be woken up at three in the morning". And that is exactly how it should be told to the customer.

Untested HA is not HA. Our configuration looked correct, all the indicators were green. Even so, the test brought out one serious gap and one performance problem. We found both on a machine with no customers, at an hour we chose ourselves.

And the test has to be done in real conditions. A test run with a tidy shutdown would have shown us neither of these two things.