High availability
High availability has a separate answer for each thing that can fail, and in Flui those answers differ. This page takes them one at a time: what happens, what Flui does about it and where the current limits are.
What can fail, and what happens
| What fails | Applications on that cluster | Your data |
|---|---|---|
| A worker | Those with two or more copies keep answering from the other nodes | Unaffected, unless a database or a volume tied to that node lived on it |
| The cluster’s master | Keep answering from the other nodes; nothing new can be deployed until it returns | Shared storage waits for the master. If the master stops abruptly, its most recent writes can be lost |
| The node a database lives on | The database is down until it is restored, unless it is highly available: then its copy on another server takes over | At most the last few minutes of changes; none when it is highly available |
| The control cluster | Keep answering | Unaffected; the dashboard, the API and central logs are gone until it returns |
To see what one of your clusters survives with the nodes it has now, and what it still needs to survive the loss of a location:
flui cluster ha <cluster>Flui offers one highly available layout: a server in each of three
locations of a region it has chosen for its provider. Where two of
the locations are close and the third is further away, the close
ones hold copies of data and the third only votes, so a write never
waits for it. Where all three are close, each holds a copy. Which
regions qualify, and the role of each location, is listed under
the providers integrated today.
The command shows each location with its role, what the cluster
survives and what is still missing, and says so when the provider
declares the locations close but Flui has not measured them yet. A
region Flui has not chosen can be forced from the command line: its
three locations are treated as equal, with no promise about how far
apart they are. Agents get the same answer from the
cluster_ha_get tool.
The dashboard shows it in the cluster’s High availability tab: each location with its role and servers, the server that leads the cluster, the one Flui reaches the cluster through, and the round trip between each pair of locations. A write that waits for another location takes at least that long. Flui measures it every ten minutes. After a loss, the lead can land in the voting location; once every server is back, Flui hands it to one in a location for data, without stopping anything.
The simplest way is to create a cluster in this layout. In the dashboard’s cluster wizard choose High availability · three locations, or from the command line:
flui cluster create <name> --ha --region fsn1 --sizes cpx22,cx23--region is where the first server goes, a location for data.
Each location takes the first size in --sizes it has available.
Before buying anything Flui checks every location; when one has
none of the sizes, nothing is bought and Flui names the sizes all
three have. Then it buys the three servers together, so none sells
out while the first one starts, and joins them one at a time. The
creation shows two moments: when the three servers form the
cluster, and when Flui has finished installing what it runs on it.
With --complete-later Flui creates the cluster in the locations
that have a size and leaves the missing server to add later.
A standard cluster can also grow into this layout, for example when a location had nothing available at creation. For each location the view lists what is still missing, a server or a node for data, and adds it:
flui cluster ha <cluster> --add server --location hel1The dashboard does the same with Add next to the missing role in the High availability tab. Flui buys the machine in that location and joins it with its role. Scaling never removes a node added this way. With two servers a cluster is more fragile than with one, because both have to answer, so add the second and the third one after the other. A lost server is not replaced this way yet: it has to be removed from the cluster first.
A worker
A cluster with at least two nodes keeps serving when a worker goes away. Flui spreads an application’s copies across nodes wherever there is room, and the application’s address points at every ready node that takes traffic. An application with two or more copies keeps answering from the ones that are left.
For about the first minute, until the cluster marks the worker as gone, some requests still go to the copy that was on it and fail. After that, the remaining copies answer every request. The copies that were on the lost worker start again elsewhere once the cluster stops waiting for it.
Once Flui has checked that every node of the cluster sees the shared storage, new volumes are not tied to the node that created them, so an application that keeps its files there starts again elsewhere with its data. Until every node sees it, new volumes stay on their node, and an application with one of them waits for that node to come back.
flui app status tells you, for each application, whether it
survives losing a worker. That needs:
- at least two copies, running on at least two nodes
- no dedicated placement, which keeps it on one node
- no volume tied to one node
- a real domain
- more than one node taking traffic
When an application falls short, the command lists each reason
with what to change. Agents get the same answer from the
app_availability tool.
The cluster’s master
Every cluster has one master. It does not sit between your users and your applications: an application’s domain points at every ready node of its cluster that takes traffic. Flui measures that set every minute and moves the name when it changes, with a one-minute lifetime on a name that points at several nodes. Clients that looked the address up before a node dropped out can take a minute or two to move on.
What still depends on the master is the cluster’s ability to change. While it is down, nothing new is deployed, lost copies are not started again, and shared storage, which is served through the master, waits for it. The data on it is kept: where the provider sells volumes, it lives on one, separate from the machine’s own disk.
The automatic address an application gets when it has no domain of its own encodes the master’s IP, so it cannot point at more than one node. An application that needs to stay up needs a real domain.
Flui runs one master per cluster. Why K3s explains how more could be added without changing how a cluster stores its state.
The node a database lives on
Databases from the catalog run as a single instance on the disk of the node they are placed on, because a local disk is the fastest thing a database can write to. This also makes that node a single point of failure for the database. If the node is lost, the database is down until it is restored on another one.
PostgreSQL and MariaDB ship every change off the cluster as it happens, so a restore loses at most the last few minutes of changes. How Flui protects data explains how this works and how to check it is on before you need it.
A PostgreSQL that survives the loss of a server or a location
A PostgreSQL from the catalog can be made highly available after it is installed, without stopping the applications that use it:
flui db ha <database> --enableThe dashboard does the same from the database’s overview, with Make highly available.
Flui builds three instances of the database, one in each of the cluster’s three locations, each on its own local disk, so it keeps the fast storage. The copies stream from the running database until they have caught up, while the applications keep working. Then writes stop for a few seconds while the copy in a close location takes over, and the applications move to it. No confirmed write is lost. The single instance is kept, stopped, with its data, as the way back.
From then on a change is confirmed once one of the two copies has it, so a write waits only for the copy that answers first, the closest one. If the primary’s database stops, the copy that has everything takes over in seconds and the applications follow it. If its whole server or location is lost, writes stop for about a minute and a half, most of it spent making sure the server is really gone, and no confirmed write is lost. While a location is away, writes are confirmed by the copy that is left, and take longer when that one is far, until the location returns.
Measured on a test cluster across Falkenstein, Nuremberg and Helsinki, a commit took about 1.5 ms on a single instance, about 8 ms highly available with the primary in Falkenstein, and about 30 ms with the primary in Helsinki, which is why Flui moves it back.
A failover can leave the primary in the far location. Once every
instance is ready again, Flui moves it back to a location for data,
with the same pause of a few seconds and no confirmed write lost,
and waits half an hour before it would move it again. flui db ha <database> and the database’s overview show where the primary is
and how far behind each copy is.
What it needs and what it does not cover yet:
- A cluster highly available across three locations. Otherwise
the request is refused with the reason;
flui cluster ha <cluster>shows what is missing, and how to add it. flui db ha <database>shows where a database stands.- Continuous backups carry on. A database whose continuous backups are on keeps them: once it is highly available, its changes go to a new place in the same storage and a first full backup is taken. Backups can also be turned on afterwards. Restoring it to a moment brings it back as a new single instance, as for any PostgreSQL.
- Its copies are Flui’s. The number of instances is not changed by hand, and the database is not stopped or started. New resources and a restart reach the instances one at a time, and the primary first hands its role to a copy, so writes pause for seconds only.
- PostgreSQL only. MariaDB and Redis follow on the same pattern.
An application’s own files
An application that keeps its files on a volume, with one copy of the application writing them, can survive the loss of its server or its location too. The volume keeps a copy in each location for data, all written at the same time: a write is confirmed only once every copy has it, which costs a few milliseconds. When the server or the location running the application is lost, the application starts again on another copy with its data, usually within a minute or two, and no confirmed write is lost. It needs a cluster highly available across three locations.
First the cluster sets this up once:
flui cluster replicated-volumes <cluster> --enableA node in each location for data sets aside part of its disk for
the copies, 20 GiB unless --size says otherwise. Where a location
only votes, it casts the deciding vote when the two copies lose
sight of each other. The dashboard does the same from the
cluster’s Storage tab, under Replicated volumes. Volumes
that already exist do not change.
Then the application asks for it on its volume, in its
flui.yaml:
deploy: volumes: - name: data mountPath: /data size: 5Gi replicated: trueWhat comes with it:
- One copy of the application at a time. A replicated volume
is attached to one server at a time, so
deploy.scalingstays at one, and every update stops the old version before it starts the new one, which takes a few seconds. - All of the application’s volumes, or none. The application moves to the other copy only when every volume can follow it, so a manifest that mixes them is refused.
- Chosen when the volume is created. A volume that already exists keeps its storage, and a deploy whose manifest says otherwise about it is refused with the reason.
- A copy can stay behind. After a short loss of the server the
application runs on, a copy can stay marked as not up to date
even though it holds all the data. Until it catches up, the
volume survives no further loss.
flui cluster replicated-volumes <cluster>and the cluster’s Storage tab name the copy and the server whose loss would stop the volume. Bringing it back means stopping the application for about a minute.
flui cluster replicated-volumes <cluster> shows where the copies
are and warns about a copy the application could not follow.
Agents get the same answers from the cluster_replicated_volumes_get
and cluster_replicated_volumes_enable tools.
The control cluster
The control cluster runs Flui itself. Losing it takes away the dashboard, the API, sign-in and the central logs and metrics. Every workload cluster keeps serving its applications, because a cluster needs the control plane only to make changes. See Failure boundaries and, for the worst case, Rebuild the control plane.
The API can run as more than one copy, which is what keeps it answering when many people use the dashboard at once:
flui app scale flui-api --replicas 2Requests are shared between the copies, and one of them runs the
scheduled work. If that copy stops, another takes over within
seconds. The count, and any CPU or memory you set on flui-api,
stays in place after a platform update. The API refuses to drop
below one copy, or to go above six unless FLUI_API_MAX_REPLICAS
allows more.
A cluster across several locations
Where a provider network spans several locations, a cluster’s nodes can sit in more than one of them, as long as its scaling group is allowed to buy there. Every node accepts traffic and copies are spread across nodes, so losing a location takes only what ran there.
Making an application highly available
- Run at least two copies. Set
deploy.scaling.min: 2in the application’sflui.yaml. - Give the cluster at least two nodes, so the copies have somewhere else to be.
- Give it a real domain, in a zone whose DNS Flui can drive (see which providers), so its address can point at every node.
- Protect the cluster, so its databases are backed up continuously and any loss is counted in minutes.
- Keep the control cluster separate from the clusters your applications run on, so a problem with one does not reach the other.
What is not here yet
- MariaDB and Redis that survive the loss of their node or of a location.
- Shared storage that does not depend on the master.