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
| Component | Potential failure | Required behavior |
|---|---|---|
| API gateway | Unavailable | Controlled error response and an alert |
| Payment ingestion | Application failure | Provider retry contract or durable recovery |
| Messaging | Queue unavailable | Durable buffering or controlled failure |
| Reconciliation worker | Consumer crash | Retry and replay |
| Database | Unavailable | Recovery with data integrity controls |
| Settlement ingestion | Invalid file | Quarantine and investigation |
| Identity provider | Unavailable | Defined access behavior |
| Reporting | Unavailable | Core 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:
| Failure | What the system does | How it recovers, and the evidence |
|---|---|---|
| The provider times out before our reply | The payment was stored once; the reply is lost | The provider retries with a new signature; the repeat gets 200 and the same ingestion ID. Evidence: one payment row |
| A downstream call times out | The outcome is unknown, so no blind retry | Ask 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 limit | After 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,000 | The 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 marking | The event is sent again: delivery is at least once | The consumer finds the event ID in processed_event and skips it. Evidence: one business change |
| A consumer crashes mid-change | Its transaction rolls back the change and the processed_event row together | The redelivered event is processed from the start |
| A poison message fails every time | Dead-letter queue after the retry limit, with the error | Fixed, then replayed through a controlled, audited replay tool |
Protect the core Graceful degradation
The numbers Availability, RTO and RPO
| Availability | Approximate 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.
| Term | Question 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.
- Failure condition and detection mechanism.
- Immediate behavior and retry or recovery strategy.
- Data integrity risk, alert and escalation path.
- 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
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.
← Lesson 07: Deployment Topology and Infrastructure Architecture