Losing a server
This page is Orbit's acceptance test for losing any one server. It first ran on three K3s servers in Docker on one machine, then on three separate servers across two providers. With the configuration below, Orbit calls this high availability: losing any one server loses no confirmed write, and the applications, the database and Orbit itself carry on from the servers left within about two minutes.
The configuration
- Kubernetes' control plane on three servers, and copies of Orbit on the two besides the main one.
- Two servers receive traffic: the main server and one more.
- An application with three instances spread over the three servers, each as large as the preview accepts while keeping room for the loss of any server.
- A PostgreSQL database with three instances, one per server, and synchronous replication.
- A client outside the cluster that writes through the application, then reads back each write the application confirmed. Like a browser with two
Arecords, it tries the second entry server when the first does not answer.
The test is TestApplicationHighAvailabilityAcceptance. It runs the scenarios one after the other, bringing the lost server back between them. The figures below are the range across the runs that reached each scenario, three to eight of them, the last of which passed every scenario.
What happened
| Loss | Writes failed for | Confirmed writes lost | Reads that missed a confirmed write |
|---|---|---|---|
| A server with an instance and the database primary | 1 minute 5 to 16 seconds | 0 | 0 |
| An entry server | 43 seconds to 1 minute 32 seconds | 0 | 0 |
| The main server, with the database primary and the active Orbit | 1 minute 34 to 54 seconds | 0 | 0 |
| The network of the server with the active Orbit and the database primary | 1 minute 3 to 15 seconds | 0 | 0 |
- Capacity: the preview accepted instances of the size the test used and refused one 30% larger. After every loss, all three instances ran again on the servers left.
- Orbit itself: after the main server was lost, a standby answered with every change after 15 to 26 seconds. After the network cut, the cut Orbit stopped answering 8 seconds after the cut, before another took over 20 to 26 seconds after it, so two never answered at once.
- The database: a new primary took over after 1 minute 20 to 39 seconds when its server was lost, and after about a minute when its network was cut. The primary cut off from the others acknowledged no write after the cut.
On real servers
The same scenarios on three separate servers: one at Hostinger (amd64) and two at Oracle Cloud (arm64), joined by Orbit's WireGuard network, with the client on a computer outside both providers. Since one image runs on one architecture, the test application ran on the two arm64 servers while the database spanned all three. The latest run of each scenario:
| Loss | Orbit version | Writes failed for | Orbit answered elsewhere after | New database primary after | Confirmed writes lost |
|---|---|---|---|---|---|
| A server with an instance and the database primary | 0.2.17 beta | 1 minute 39 seconds | Not targeted | Within 2 minutes 12 seconds | 0 |
| An entry server | 0.2.17 beta | 1 minute 23 seconds | Not targeted | Not targeted | 0 |
| The main server, with the database primary and the active Orbit | 0.2.18 beta | 1 minute 46 seconds | 39 seconds | 1 minute 45 seconds | 0 |
| The network of the server with the active Orbit and the database primary | 0.2.18 beta | 1 minute 46 seconds | 55 seconds | 1 minute 44 seconds | 0 |
- No read missed a confirmed write in any scenario, and after every loss the application ran three instances again on the servers left.
- Orbit itself took the lease about 16 seconds after the network cut; the rest of the 55 seconds is the console answering at the other address with every change.
- What the real fleet found first. Before these passed, the runs on real servers showed that a standby could hang on a copy interrupted by a restart, that k3s exited when its controller manager could not renew a lease during an etcd leader change, that every restart of the active Orbit made the standbys copy the database again, and that a clean stop took 30 seconds and handed the lease over before its last writes reached the standbys. Each was fixed and measured again.
- Room after a loss. The first attempt at the network cut also showed that the servers left must have room for every instance: applications deployed after the test application had filled one arm64 server to 93% of its CPU, so the third instance waited until the cut ended. Orbit checks that room when you place or resize an application, not yet when other services fill those servers later.
The run, its setup and every measurement are in docs/ha-checklist.md.
What it means
- No confirmed write was lost, and no read missed a write the application had confirmed, in any scenario.
- Writes stop while the database fails over. When the server with the primary is lost, writes fail until Kubernetes declares that server lost and the database promotes a replica, about a minute and a half.
- Requests to the lost server's instance fail until Kubernetes declares the server lost, about a minute, even when the database is elsewhere.
- Visitors whose DNS picked a lost entry server depend on their client trying the other address, as browsers and
curldo. - Right after a server comes back, Kubernetes puts its own services, DNS among them, back on the main server, and Orbit spreads them over the control plane servers again within 20 seconds. Losing the main server in those seconds leaves the cluster without DNS until it returns.
Running it on your servers
The same scenarios run on three real servers with TestApplicationHighAvailabilityOnServers, from the Orbit repository, against an Orbit you installed. It takes the three addresses, the console address, an API token with the admin role, the test application's domain and the application's and database's ids, then reboots each server over SSH (or waits for you to power it off, with ORBIT_HA_LOSS=manual), cuts one server's network, and measures from your computer the way the client above does. It prints the row for the results table in the repository's checklist. The setup it expects, the variables and what it checks are in docs/ha-checklist.md.
Two things the real fleet taught the runner. One image runs on one architecture, so on a fleet that mixes amd64 and arm64 the application is placed on the servers of one architecture while the database spans all three; the runner accepts that and still expects three ready instances. And before it cuts the active server, it waits until every standby follows the active Orbit's current generation, because a standby that is still downloading the database after a restart cannot take over, whatever the lease says.
What it does not cover
- Fixed in 0.1.42: in one early run, writes had not come back three minutes after losing the main server. A server that had come back earlier had put Kubernetes' DNS on the main server only, so losing the main server left the cluster without DNS: the database replica could not reach the new primary, and every write waited for it. Orbit now keeps those services spread, and the test checks that DNS runs on two servers before every loss. Losing the main server then passed six times in a row on the same cluster, with writes back after 1 minute 4 to 39 seconds.
- With an application on two servers, the one left must hold every instance. Orbit checks this when the application is placed or resized; a service deployed later on the same servers can take that room without a warning yet.
- Losing two servers at once stops the control plane and the database.
- Builds after the main server is lost wait for BuildKit to install on the new active server, and generated sslip.io addresses point to the main server.