MySQL, MariaDB, Valkey: failover in under 40 seconds

One database per engine, 1,500 witness rows, and the database machine stopped at once: failover in 31 to 40 seconds, no row lost. Then planned failovers of 5 to 15 seconds, and the two defects the test made us fix first.

A dashed, crossed-out database on the left; an arrow to a lit database on the right; below, a timeline of writes with a short gap

Since December 1, 2026, high availability and read replicas are no longer limited to PostgreSQL: MySQL, MariaDB and Valkey have them too. A database with high availability has a standby, a copy kept up to date continuously on separate hardware, that takes its place by itself if it goes down.

Before announcing it, we tried it in production on our own account: one database per engine, witness data, then outages we caused and planned failovers. The times below come from the logs of the console and of the machines, in Montréal time. The test also brought out two defects, fixed the same day before the outages; section 2 tells how. How managed databases work in general is described in Managed databases in Montréal, a walkthrough.

1. The setup

Three databases of the smallest size (1 GB, 0.020 CAD an hour), in the same private network: MySQL 8.4 (Percona Server), MariaDB 11.8 and Valkey 8.1. In each, a table of 1,000 witness rows (Valkey: 1,000 keys), then high availability. For a customer, it takes one call:

bash
curl -s -X PUT https://api.ffxf.net/v1/databases/52/high-availability \
     -H "Authorization: Bearer $FFXF_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"enabled": true}'

or at order time, with "high_availability": true in POST /v1/databases. The standby starts from the latest backup of the database (Valkey: from a transfer over the network), catches up with what was written since, then follows every change. It sits on other hardware than the database, serves no queries, and does not show up as a database of its own in the console. The database's availability does: preparing, then ready.

2. What the test fixed before the outages

The setup brought out two defects, before any outage: an install that could stop halfway on a new machine, and a MySQL standby that would not start. Both were fixed and deployed the same day; the measurements in the next sections were taken afterwards.

3. Outage 1: the Valkey database machine stops dead

The standby had been following the database, with no lag, since 13:19:53. Right before the outage, 500 more keys: 1,500 on the database, 1,500 on the standby. At 13:21:04, the database machine is stopped at once, with no clean shutdown, like a power cut:

On the new machine: the 1,500 keys, a write accepted, and the database's private name pointing at it. Backups resumed right away, and a new standby was ordered by itself, on other hardware. The former machine was destroyed.

4. Outages 2 and 3: MySQL and MariaDB

The same for the other two databases, after 500 more rows in each:

In all three cases, the standby became the database about ten seconds after the failover, with every witness row, and a write was accepted at once. For PostgreSQL, the same outage took 39 seconds on November 30. Replication stays asynchronous: a write committed in the very last moments before the outage could be missing. Our witness rows were written a few seconds before; none was missing.

5. After the failover: backups and a new standby

With MySQL and MariaDB, the promoted machine resumes backups with a full one: started 12 seconds after its promotion, done in 4 seconds for the test's MySQL database.

The new standby starts from that backup, not an older one. For the MySQL database, it caught up with the writes that followed, then followed the database directly; it was streaming at 13:41:02, ten minutes after the outage, machine creation included. A restore to the minute is still possible on both sides of the failover; between the failover and the end of that first backup (a few seconds here), it gives the database as it was at the failover.

6. Maintenance: a failover with no loss

Weekly updates of a database with high availability are applied to the standby first, which then takes the place of the database. This time nothing breaks: the database stops cleanly, once it has sent everything to the standby. MySQL and MariaDB first turn read-only until the standby has received the last binlog. We triggered this failover by hand on each database, right after writing 500 more rows (or keys):

The time runs from the failover request to the standby taking over. The database accepts writes again about ten seconds later, once the standby is promoted.

7. Why 30 to 40 seconds

Failing over too fast would be worse than failing over late: a database that is alive but briefly unreachable would end up duplicated. So the console requires two signs at once: the database has not answered for 30 seconds, and its standby lost it 20 seconds ago. A standby that still receives the database proves it is alive, even if the console no longer sees it.

The other guard is on the database itself. If it loses both the console and its standby for 20 seconds, it turns read-only and closes its sessions before the standby can take its place. A database cut off from the network but still running therefore stops taking writes before another one starts.

8. What high availability costs

The standby is billed like the database, at the same period. It does not count in the database quota.

The three test databases, their successive standbys and the replaced machines cost less than a dollar for the afternoon. Everything was deleted afterwards.

9. Takeaways

  • MySQL, MariaDB and Valkey now have high availability and read replicas, like PostgreSQL, through the console, the API or the MCP server.
  • Database machine stopped dead: failover in 31 to 40 seconds, then writes accepted about ten seconds later. No witness row lost.
  • Updates: a planned failover of 5 to 15 seconds, with no write lost.
  • After a MySQL or MariaDB failover, the new machine takes a full backup right away, and the new standby starts from it.
  • On the application side: go through the database's host name, never its address, and plan for reconnecting.

The details are in the databases documentation, and high availability for a website, on the machine side, in High availability: load balancer, two VMs, an outage.

An application reads a memory block marked with a lightning bolt first, over a short path; a slow database with a clock is only reached at the end of a dotted path

Managed Valkey: a Redis-compatible cache, measured

A 1 GB Valkey database and a Nano on the same private network. A 214 ms SQLite read drops to 0.17 ms once cached, a GET costs 0.1 ms over TLS, and a full database refuses writes until it moves to allkeys-lru. Numbers, clients and limits.

Read the article 8 min read

A PostgreSQL database linked to three copies, a backup, a restore to a chosen minute and a fork, each marked with a verified fingerprint

Managed PostgreSQL: backup, restore and fork, timed

A 1 GB managed PostgreSQL database, 5 million rows, an UPDATE without a WHERE. A 30-second backup, a restore to the minute in six minutes, a fork copied in 35 seconds, and matching checksums every time.

Read the article 8 min read

Support & discussions

Technical questions, incident reports, or infrastructure discussions, the team is reachable on Discord, Telegram, X, Instagram, Reddit, and IRC.