Video in progress

Staff 🌱 Spring

How do you plan disaster recovery for Spring services and their databases? Who sets RPO and RTO, and how?

RPO (how much data loss we can tolerate) and RTO (how fast we recover) are agreed with the business per service. They determine the backup type, replication, the standby region and the recovery drills. A backup that hasn't been tested is not a backup.

📖 Answer

  1. Goals come from the business. I don't start from a technical decision but from a question: "If the payment service is down for 1 hour, how much does the company lose? What if the last 5 minutes of payments are lost?" The services then get split into classes:
Class Example RPO RTO
Critical payments, accounts ~0 < 15 min
Important orders, catalog < 5 min < 1 hour
Secondary recommendations, analytics < 24 hours < 1 day

Every step up has a price; saying "everything is critical" eats the whole budget.

  1. Technical measures by class.
  • Backup: full + WAL archiving (PostgreSQL PITR), so you can go back to any minute. The backup lives in another account/region and is immutable, which protects against ransomware and "admin mistakes".
  • Replication: a synchronous replica gives RPO≈0, but write latency rises; asynchronous is faster, but on failover the last seconds may be lost.
  • Standby region: for the critical class, data replication and application pods that are ready (warm standby). For the others, infrastructure as code that is brought up when needed.
  • Object storage, Kafka, Redis, secrets: don't forget the state outside the database. The restored database and files must match the same point in time.
  1. The application side.
  • Configuration and addresses are not tied to a region (through DNS, service discovery).
  • After a failover, idempotency and reconciliation: compare transactions lost in asynchronous replication against external systems (the payment provider).
  1. Drills. Every quarter a real restore: restore from backup into a separate environment and measure the time; once or twice a year a region failover drill (a game day). The runbook is step by step and was updated at the last drill. Many companies find out during their first real incident that the backups don't work or that recovery takes 3 times longer.

RTO and RPO should not be numbers in a document, but numbers measured in the last drill.