What happens when something breaks
We stopped VectoGrid's main database server in production while it was taking writes. For 8.8 seconds, new writes paused. Then the standby took over. We checked all 1,588 writes the database had confirmed. Every one was there.
A crashed program, a failed server and an accidental deletion each need a different response.
| What breaks | What happens |
|---|---|
| A program crashes | Another copy answers requests while the failed program restarts. |
| A server goes down | The effect depends on what it was doing. In our document-store test, the first upload took 2.9 seconds and succeeded. In our database test, writes paused while the standby took over. |
| Something is deleted or corrupted | Live copies reproduce the mistake. Hosted documents have 30 days of version history. We also take nightly backups and lock each one against deletion for 14 days. |
1. A program crashes
Several programs work on your documents. The API answers your browser, workers process documents, the search index makes them searchable, and the database and document store hold the data. Each program runs in its own container. A stopped program restarts within seconds. StackGrid, the platform we deploy with, also checks for programs that are running but have stopped responding and restarts them.
Seconds of errors are still errors. That's why the programs that answer requests run on more than one server. An nginx relay knows where the copies are. If one fails to answer, the relay tries another. Your browser keeps using the same address. The time it takes the relay to give up on the first copy can show up as a slow request. We measured one below.
2. A server goes down
Your documents
On our hosted service, your files live in Hetzner object storage in Germany. Hetzner stores them redundantly within its data centre, so stopping one of VectoGrid's application servers leaves the files in place. We encrypt each file before sending it, and the encryption key stays with us. The store also keeps earlier versions for 30 days, so we can recover a file that someone overwrote or deleted.
If you run VectoGrid on your own servers, your files go to Garage, an open-source document store that speaks the Amazon S3 interface. We run it across three servers. Garage aims to keep each file on all three and acknowledges an upload once two have it. A read asks two servers. Picture a file that has reached servers A and B when A goes down. A reader can still ask B and C, and B has the file. That overlap is the reason for using three servers and waiting for two.
We tried it
We stopped the Garage process on one of three production servers, using the configuration we deploy for self-hosted installations. From an application server, we wrote and read a small file through the usual address. Each figure below is the time for one request.
| Document-store state | Write | Read | What we found |
|---|---|---|---|
| All three servers available | 13 ms | 48 ms | The file read back correctly |
| One stopped, first attempt | 2.9 s | 60 ms | The file read back correctly |
| One stopped, next attempt | 26 ms | 19 ms | The file read back correctly |
| Stopped process restarted | 41 ms | 36 ms | Files written during the outage were readable too |
The first upload took 2.9 seconds while nginx waited for the unavailable server and tried another. The next upload took 26 milliseconds with that server still down. In an earlier run on three test machines, the returning server caught up 30 seconds after it restarted.
The search index
A search may need to look through several parts of an index. Qdrant calls each part a shard. If even one shard were unavailable, a search could miss documents. We keep each shard on two different servers out of three, so a surviving copy of every shard is available when one server goes down.
Qdrant uses a majority vote, through a protocol called Raft, to keep its map of those copies consistent. StackGrid manages their placement. If a server stays down for five minutes, StackGrid copies the affected shards onto the remaining servers to bring them back to two copies each. We tested search-index failover on test machines.
The database
Two servers hold the Postgres database. The main accepts changes and records them on its own disk in a write-ahead log. The standby receives that log and replays it into its own copy. While both servers are healthy, the main waits for the standby to record a change before telling the application it succeeded. This adds a few milliseconds to a write. When we checked, the standby was zero bytes behind.
Why have a third server if two already hold the data? Imagine the connection between the two breaks. From the standby's point of view, the main has gone silent. Meanwhile, the main may still be answering customers. If the standby starts taking writes as well, two customers can each receive a successful response while their changes go into different databases. This is called split brain. Repairing it means choosing which changes to keep.
The third server gives the system a way to settle who may take writes. It holds a vote and no customer database. Across the three servers, a small store called etcd keeps a record of which database server holds the right to act as main. That right expires unless it is renewed, and renewal requires agreement from two of the three. Patroni runs beside each copy of Postgres and uses that record to decide whether its copy may accept writes. A main that loses contact with the majority must stop taking writes when its claim expires.
This answers a different question from the one Qdrant votes on. For search, the servers need to agree on where the shard copies are. For Postgres, they need to agree on which one of the two database servers may tell a customer that a change has been saved.
If the main goes down, the standby can take over once it and the third voter have a majority. In our production test, we attempted a write every tenth of a second and stopped the main. The standby took over in 8.8 seconds. We found all 1,588 confirmed writes afterward. When the old main returned, it rejoined as a standby on its own. Moving the main role back on purpose took 4.2 seconds.
If the standby goes down, you can still save. The main continues confirming changes on its own disk and keeps the log entries the standby needs, so the standby catches up when it returns. Until then, a new save lives on one server; losing that server's disk in that window would lose those saves.
Your working session
The API runs on two servers. The relay normally sends a given session back to the same server so it can use what it already has in memory. If that server goes down, the other reloads the session from storage.
To choose a server, the relay uses consistent hashing: it places each server and each session id on an imaginary circle, and a session goes to the next server around the circle. With a plain "id modulo number of servers", going from two servers to three would send almost every session to a new server, and each would have to reload. On the circle, a third server picks up only the sessions just before it, roughly a third of the total. The others keep going where they went before. So we can add capacity without making every active session reload at once.
The hard case: a main server that only seems dead
It's tempting to give one outside program the job of watching the main and promoting the standby when the main stops answering. The difficulty is that the watcher and your application may see different things. A broken link can leave the watcher unable to reach a perfectly live database. Promoting the standby at that point leaves the old main free to keep taking writes over connections that are already open.
This is not a theoretical risk. GitHub's outage of October 2018 began with a 43-second network cut between two of its sites. Its databases switched over automatically, writes landed on both sides, and putting the data back together took 24 hours of degraded service. A network problem or a frozen machine lasting half a minute happens to every system sooner or later.
We saw another weakness of an outside watcher while writing this article. The server running StackGrid spent over an hour stuck in a resize at our hosting provider. The databases kept running. If switching depended entirely on StackGrid and a main had failed during that hour, the standby would have kept waiting. This is why our Postgres setup puts the decision with Patroni and etcd.
Where StackGrid acts as the outside watcher for simpler installations, it must establish that the old main has stopped taking writes before it promotes a replacement. It first tries to stop the database directly. If it cannot reach the machine, it uses the cloud provider's controls to power it off and waits for confirmation. If it can confirm neither, it leaves promotion on hold: a short outage is better than two main servers. The relays also close existing connections to the old main.
We tested three database setups on three servers each. We attempted a write every tenth of a second while stopping the main, isolating it on the network while it was still running, freezing a voter and rebooting the old main.
| What we measured | Postgres with Patroni and etcd | Redis with Sentinel | MySQL with Group Replication |
|---|---|---|---|
| Pause in writes after stopping the main | 7–9 seconds | 7–14 seconds | 24 seconds |
| What the isolated main did | Accepted no writes | Refused writes after about 5 seconds | Went read-only |
| When the old main returned | Rejoined as standby | Rejoined as replica | Rejoined the group |
| Confirmed writes lost | 0 of 1,273 | 0, for writes that asked to wait for a copy | 0 of 622 |
The five-second Redis window matters. Redis copies changes asynchronously. During that window, a customer can receive confirmation from the isolated main before a replica has the write, and that write can disappear when the servers rejoin. In our test, every write that waited for a replica survived. In a separate production run, Redis switched over in 7.8 seconds, and we found all 689 confirmed test writes afterward.
How a majority vote picks one leader (Raft, in one minute)
Raft keeps a few servers (three or five) agreeing on one shared record, and on which of them leads.
- One leader at a time. Each server is a follower, a candidate or the leader. The leader sends a short heartbeat to the others several times a second.
- Elections. A follower that hears no heartbeat for a random fraction of a second becomes a candidate and asks the others for their vote. Each server votes once per round ("term"), so at most one candidate can collect a majority. The random wait keeps two candidates from splitting the vote again and again.
- Writes. The leader appends each change to its log and sends it to the followers. The change is final ("committed") once a majority has stored it, and only then is it applied.
- Why it is safe. Any two majorities of the same group share at least one server. So a new leader always has every committed change, and an old leader cut off from the majority can no longer commit anything: its writes go nowhere, and it steps down when it hears of a newer term.
- How many failures it survives. Three servers keep working with one down, five with two down. Two servers survive none, since one alone is never a majority.
etcd does for Postgres what ZooKeeper does for Hadoop and long did for Kafka. Garage's two-of-three reads and writes use the same overlap of majorities, without a leader. The original paper, readable in an evening: raft.github.io.
3. Something is deleted or corrupted
Copies are for failed machines; backups are for mistakes. Suppose a bad update overwrites a table. The standby faithfully replays the change. Within milliseconds we can have two healthy databases containing the same mistake. To recover, we need a copy from before the update.
Every night we back up the database, search index and job queue. Self-hosted installations also back up the document store. On our hosted service, the document store keeps its own 30-day version history.
Each nightly backup is encrypted on the server with an age public key before it leaves. The servers never hold the matching private key, so someone who takes over a server cannot read a single backup. The private key is kept offline for recovery. The backup goes to separate object storage, where a compliance lock prevents anyone from overwriting or deleting it for 14 days, including us. We tried to delete a locked backup. The store refused. Backups are removed after 30 days. The disks holding VectoGrid's live data are encrypted too.
What we have restored
We downloaded and decrypted the first night's backups. The Postgres backup contained 129 tables, and the document-store backup opened as a readable archive.
On test machines, we restored a database and a search index filled with known data. We ran the restore from both the local backup and the separately stored copy. Every database row and search point came back. We also compared the production backups with the running service. We found the same tables and the same 139,335 search points. Six log tables had grown since the backup was taken.
The remaining drill is to rebuild a whole service from scratch and open a recovered document through the application. We have tested the component restores. That end-to-end recovery time is still unmeasured.
For a single hosted document overwritten by mistake, the 30-day version history lets us recover an earlier version of that file. A whole-database restore returns the database to the time of the chosen backup, so later changes are absent from the restored copy.
The same set-up runs on our servers, at another cloud provider or in your own data centre: nothing in it depends on one vendor.
Want to run VectoGrid on infrastructure you control?
Published 23 November 2026 · Revised 25 November 2026 · Philippe Vergnet, VectoGrid