Reliability, Failure Handling and Disaster Recovery

Designing for failure: critical failure points, availability arithmetic, RTO and RPO, graceful degradation, controlled replay and safe deployments.

  • Intermediate to advanced
  • About 19 minutes
  • Includes an exercise and a knowledge check

The concept Working in a demo is not reliability

An enterprise system must keep behaving correctly when parts fail. A provider repeats a notification; the reconciliation processor goes down; the database connection pool runs out; a settlement file is incomplete; a message is delivered but not processed; a deployment introduces a defect; a cloud region has a major outage. A production architecture says what happens in each case.

Find them first Critical failure points

ComponentPotential failureRequired behavior
API gatewayUnavailableControlled error response and an alert
Payment ingestionApplication failureProvider retry contract or durable recovery
MessagingQueue unavailableDurable buffering or controlled failure
Reconciliation workerConsumer crashRetry and replay
DatabaseUnavailableRecovery with data integrity controls
Settlement ingestionInvalid fileQuarantine and investigation
Identity providerUnavailableDefined access behavior
ReportingUnavailableCore processing continues independently

The required behavior depends on business priorities. Reporting being down for a while should not stop payment ingestion. That is one reason to separate capabilities and failure domains.

Step by step Failure paths, written out

A required behavior is not enough on its own; the path back to a correct state must be written down too. These are the failures Module 07 implements and Module 08 tests:

FailureWhat the system doesHow it recovers, and the evidence
The provider times out before our replyThe payment was stored once; the reply is lostThe provider retries with a new signature; the repeat gets 200 and the same ingestion ID. Evidence: one payment row
A downstream call times outThe outcome is unknown, so no blind retryAsk the downstream system by idempotency key, or retry with the same key so it can refuse a second effect. Evidence: its audit log
A transient error (network, 503)Retry with exponential backoff and jitter, up to a limitAfter the limit, the message goes to the dead-letter queue with its reason and an alert
A batch fails part-way through, at line 4,000 of 10,000The batch stays PROCESSING; lines are unique by (batch, line number)A restart resumes without duplicating lines; COMPLETED only after the totals check
The outbox publisher crashes after sending, before markingThe event is sent again: delivery is at least onceThe consumer finds the event ID in processed_event and skips it. Evidence: one business change
A consumer crashes mid-changeIts transaction rolls back the change and the processed_event row togetherThe redelivered event is processed from the start
A poison message fails every timeDead-letter queue after the retry limit, with the errorFixed, then replayed through a controlled, audited replay tool

Protect the core Graceful degradation

On the left, a photo of rows of backup generators beside a data center, ready before the outage. On the right, when this fails, the platform does this. Reporting is down: ingestion and reconciliation keep running. Notifications fail: the exception is kept and the notification retried later. The reconciliation worker is down: payments wait in the durable queue, then catch up. The identity provider is down: sensitive operations are blocked, never unchecked. Decide before the outage what keeps running, what pauses and what stops, and agree these priorities with the customer.
Backup power is installed before the storm. Decide what keeps running before the outage, too.

The numbers Availability, RTO and RPO

AvailabilityApproximate downtime per year
99%3.65 days
99.9%8.76 hours
99.95%4.38 hours
99.99%52.6 minutes

These are arithmetic, not Apex’s agreed objectives. The customer sets availability targets from business impact, and a finance investigation screen and the payment ingestion endpoint may need different targets.

Left, bars of approximate downtime a year: 99 percent about 3.65 days, 99.9 percent about 8.76 hours, 99.95 percent about 4.38 hours, 99.99 percent about 52.6 minutes. Right, a recovery timeline: the last recoverable point of data, then the failure, then service restored. The gap before the failure is the RPO, data that may be lost; the gap after it is the RTO, the time the service is down. Example: an agreed RPO of five minutes means recovery may lose at most the last five minutes of data. Never assign these values yourself.
Ask the customer: how long can we be down, and how much data can we lose?
TermQuestion it answers
Recovery Time Objective (RTO)How long can the system be unavailable before recovery must be complete?
Recovery Point Objective (RPO)How much data loss, measured in time, can the business tolerate?

After the failure Recovery and replay

  • Can failed messages be replayed, and can a settlement file be reprocessed?
  • Can a reconciliation result be recalculated?
  • How do we stop replay from creating duplicate financial effects?
  • Who may start a recovery, and is the replay recorded in the audit history?

Reprocessing is controlled, traceable and idempotent. A replay never silently overwrites historical results. When business rules change, keep the rule version used for the original result and record the new evaluation separately.

Releases fail too Deployment safety

Useful techniques: automated tests, infrastructure validation, progressive and canary releases, blue/green deployment where appropriate, rollback procedures, feature flags, compatible database migrations and post-deployment checks. A rollback is not always just deploying the older version: if the database schema changed, the old code must still work with it.

Practice Design failure and recovery

Practical exercise

Exercise 08: the failure matrix

Write a failure matrix with at least ten scenarios, and propose RTO and RPO as questions for the customer, not as facts.

  1. Failure condition and detection mechanism.
  2. Immediate behavior and retry or recovery strategy.
  3. Data integrity risk, alert and escalation path.
  4. Recovery authorization and the evidence kept for audit.
Show a sample row
  • Failure: settlement file is missing at its expected time.
  • Detection: a scheduled check finds no file by the agreed deadline.
  • Behavior: payments stay AWAITING_SETTLEMENT; the dashboard shows the delay; nothing is marked failed.
  • Recovery: reprocess the file when it arrives; duplicate records ignored by unique bank reference.
  • Escalation: finance operations and the bank contact; authorization: platform on-call starts the reprocessing; evidence: file receipt log and audit entries.
  • Question for Apex: what RTO and RPO does payment ingestion need, and are they different for reporting?

3 questions

Check your understanding

1. What does RPO represent?
2. Reporting is unavailable. What should happen to payment ingestion?
3. A matching rule changed. How should historical results be handled?
Answer every question to submit.

What you can do now

  • Find critical failure points and define the required behavior.
  • Explain availability, RTO and RPO, and ask for them.
  • Design graceful degradation that never weakens security.
  • Plan controlled replay and safe deployments.