SysDesignPrep.com
Interactive concepts

RPO and RTO explained: an interactive backup and disaster recovery simulator

Every data protection plan answers two questions. How much data can we lose? That is the recovery point objective (RPO). How long can we be down? That is the recovery time objective (RTO). Backups, log archiving and replicas trade these against cost, and they protect against different disasters: a replica saves you from a lost data center but copies a mistaken DELETE within seconds.

The playground runs a day of a database with a backup at midnight. Pick a disaster and a time, and compare what five strategies lose and how long each takes to recover.

DisasterSize

At 8 p.m. the 500 GB database's region goes down, disks and all. Last night's backup brings back the data as of midnight: 20 h of writes gone and 32 min to restore. Archiving the write-ahead log every minute cuts the loss to 1 min, but replaying 20 hours of log makes recovery take 65 min. A standby in another region is promoted in 5 min, losing only the 2 s it was behind; a synchronous standby loses nothing, at the cost of 60 ms on every commit.

midnight6 a.m.12 p.m.6 p.m.midnight
Nightly backupa full copy to object storage at midnight20 h of writesback in 32 min
Backup + WAL archivenightly base backup, write-ahead log shipped every minute1 min of writesback in 65 min
Async replicaa standby in another region, a few seconds behind2 s of writesback in 5 min
Sync replicaevery commit waits for the standby in another regionnothingback in 5 min
Async replica + WAL archivea standby for outages, the log archive for mistakes2 s of writesback in 5 min

What each costs beyond the database: Nightly backup: backup storage. Backup + WAL archive: backup and log storage. Async replica: a second database server. Sync replica: a second server, +60 ms per commit. Async replica + WAL archive: a second server and log storage.

writes lost (RPO)until the data is back (RTO)full backuplog archived

Outages: replicas win

If the region holding a 500 GB database fails at 8 p.m., last night’s backup brings back the data as of midnight: 20 hours of writes lost, and about half an hour to provision a server and restore it. Archiving the write-ahead log every minute cuts the loss to about a minute, but recovery now replays 20 hours of log and takes over an hour, and for a 5 TB database the restore alone takes about three hours. A standby in another region is promoted in minutes and loses only the seconds it was behind; a synchronous standby loses nothing, but every commit waits for a cross-region round trip.

Mistakes: only history helps

An accidental DELETE, a bad migration or a bug that corrupts rows is replicated just like a good write, so every standby holds the same damage within seconds. What recovers it is history: a backup plus the archived log lets you restore to one second before the mistake, on a separate server, and copy the lost rows back without losing anything written since. A nightly backup alone loses everything since midnight. That is why serious setups combine both: replicas for availability, a log archive for point-in-time recovery, and a delayed replica or snapshots as a faster path for recent mistakes.

  • Test restores. A backup you have never restored is a hope, not a backup. Restore regularly and time it: that is your real RTO.
  • Keep copies apart. Store backups in another region and another account, so the same outage, or the same compromised credentials, cannot destroy both.
  • Size RTO with data. Restore time grows with database size; at a few TB, restoring from backup takes hours, which pushes large systems towards replicas and smaller shards.

Continuous archiving in PostgreSQL

# postgresql.conf: ship every write-ahead log segment to object storage
archive_mode = on
archive_command = 'wal-g wal-push %p'   # or pgBackRest, Barman
archive_timeout = 60                    # ship at least once a minute: RPO of about a minute

# nightly:   wal-g backup-push $PGDATA
# restore to one second before the mistake:
#   wal-g backup-fetch $PGDATA LATEST
#   recovery_target_time = '2026-10-23 19:59:59'
#   restore_command = 'wal-g wal-fetch %f %p'

In a system design interview

State the objectives and match each failure to a mechanism: “Payments need an RPO of zero and an RTO of minutes, so the ledger database has a synchronous standby in a second zone and an async one in another region. For mistakes and corruption, base backups go to object storage nightly with continuous log archiving, kept 30 days in a separate account, so we can restore to any second. We run a restore drill every month.” Expect the follow-ups: split brain during failover, the latency of synchronous replication, and how backups handle data deletion requests for privacy.

Read the guide to backups and disaster recovery or multi-region design, see database failover and the write-ahead log, or watch a strong candidate design a payment system.

Questions people ask

What is the difference between RPO and RTO?

The recovery point objective is how much data you can afford to lose, measured as time before the failure; the recovery time objective is how long you can afford to be down. A nightly backup has an RPO of up to a day; a synchronous replica has an RPO of zero.

Are replicas a substitute for backups?

No. Replicas protect against losing a server or a region, but they copy every change, including an accidental DELETE, a bad migration or corruption, within seconds. Recovering from those needs backups or a log archive that can restore an earlier point in time.

What is point-in-time recovery?

Restoring a database to any chosen moment by restoring a base backup and replaying the archived write-ahead log up to that moment. It lets you recover to one second before a mistake, rather than only to the time of the last backup.

How long does it take to restore a database from backup?

Roughly the time to provision a server, copy the backup at the restore throughput, and replay any log since the backup. At 500 MB/s a 5 TB backup takes close to three hours to copy, which is why large systems rely on replicas for fast recovery.

What does synchronous replication cost?

Every commit waits until the standby confirms it has the change, so commit latency includes a round trip to the standby: about a millisecond within a region, tens of milliseconds across regions. In exchange, a failover loses no committed data.

What is a delayed replica?

A standby that applies changes only after a fixed delay, such as an hour. If someone deletes data by mistake, the delayed replica still has it for that hour, giving a fast way to recover recent mistakes without a full restore.

How often should you test backups?

Regularly, ideally automatically: restore a recent backup to a scratch server, check it, and record how long it took. The measured restore time is your real RTO, and an untested backup may fail exactly when it is needed.