High Availability Patterns: A Decision Guide
Choose an availability target, calculate its downtime budget, and plan service recovery with a checkout example and clear SLI assumptions.
Availability decisions start with a service level indicator and a budget, not a target picked by habit. This guide calculates time-based downtime, then walks through a checkout API with an optional recommendation service and database failover to show what the design protects and what it cannot promise.
High Availability Patterns: A Decision Guide
Availability design starts with a question: when one part of the service fails, which requests should still succeed, and what data can be lost or delayed? Redundancy and failover help answer that question, but they add cost and failure modes of their own.
This page is a decision guide, not a manual for every pattern. It follows one checkout service through a dependency outage and a database failover, then shows how to calculate a time-based downtime budget. For implementation mechanics, see the focused guides linked at each decision.
Choose a measure before a pattern
Time-based availability is the share of a period when a service is available:
time-based availability = (period - unavailable time) / period
This is easy to calculate when the service is either available or down. It can hide partial failures. If some application instances fail, or errors affect a slice of traffic, a request-based service level indicator (SLI) is often more useful:
request success SLI = successful eligible requests / total eligible requests
Define what counts as an eligible request and what counts as success for your service. Google’s SRE availability table notes that aggregate failed operations can better represent services with partial outages or variable traffic than outage duration alone. See the availability table and the API latency and error budget guide for SLI and SLO choices.
Calculate a time-based budget
Use the target as a decimal and multiply the period by the fraction allowed to be unavailable:
allowed downtime = period × (1 - availability target)
For a 365-day year and a 99.9% target, use the full year as the measurement period and count planned maintenance as unavailable:
365 days × 24 hours = 8,760 hours
8,760 × (1 - 0.999) = 8.76 hours
That is 8 hours, 45 minutes, and 36 seconds of allowed unavailability for the year. Google’s SRE table lists the same annual value under a no-planned-downtime assumption. For your SLI, state whether planned maintenance counts; exclusions change what this budget means.
This number is a budget under the stated measurement rule, not a promise that outages will be shorter. A request-based SLI has a different denominator and cannot be converted into downtime hours without traffic assumptions.
Walk one checkout request
Consider a checkout API behind a load balancer. It writes an order to a database, calls a payment service, and requests recommendations for a confirmation page. Recommendations are useful but not required to place the order.
| Failure | What checkout should decide | Trade-off |
|---|---|---|
| One API instance stops serving | Route new requests to ready instances and remove the failed instance from rotation. | This covers an instance failure only; it does not fix a shared database or network problem. |
| Recommendation service times out | Return the order confirmation without recommendations, and stop sending a burst of retries to the failing service. | Users lose optional content while the core order path remains usable. |
| Primary database becomes unreachable | Follow a defined promotion or recovery process; do not report a write as accepted until it is durably recorded. | Faster recovery may allow some recent writes to be missing if replication was asynchronous. |
| A network partition separates database nodes | Decide which side can accept writes and what the other side returns. | The consistency and availability behavior during a partition needs an explicit system policy; see the CAP theorem guide. |
For the first failure, a load balancer can route around an unhealthy stateless API instance. It cannot restore a failed database. Keep readiness checks tied to whether that instance can serve its required paths; if an optional recommendation dependency is down, marking every API instance unhealthy may take the whole service out of rotation. The load balancing guide covers traffic routing, and failover automation covers health checks and database promotion.
For the recommendation timeout, set a bounded timeout and use a fallback that does not block checkout. A circuit breaker can stop repeated calls while the dependency recovers. It limits the damage from a dependency failure; it does not make that dependency healthy. See graceful degradation patterns for fallback and circuit breaker mechanics.
For database recovery, decide the recovery time objective (RTO) and recovery point objective (RPO). RTO is the target time to restore service after a disruption. RPO is the maximum amount of recent data the system can lose, expressed as a time window. With asynchronous replication, a promoted replica may not contain every recent acknowledged write, depending on lag and the database’s guarantees. Test the exact recovery procedure and record its measured behavior; do not infer zero data loss from the word “failover”.
Finally, measure the checkout path from the caller’s perspective. An SLI might count successful, valid checkout requests over all valid attempts. Alert when that SLI burns its error budget quickly, and attach a response the on-call can take. The alerting guide covers signal and threshold choices; alerting in production covers pages and runbooks.
Use this decision guide
- If an instance can fail independently, run enough instances to survive that loss and route around unhealthy ones. Check that they do not all depend on the same zone, network path, or database.
- If a dependency is optional, decide what the user sees when it is slow or unavailable. Use a simple fallback before adding another replica of a feature the main transaction does not need.
- If state must survive a primary failure, choose replication and promotion behavior from the required RTO and RPO. Include possible data loss, stale reads, split-brain prevention, and operator recovery in the decision.
- If a whole zone or region is in scope, compare the failure you need to survive with the added replication, routing, consistency, and operating costs. Multi-region deployment does not make every dependency independent.
- If the service is partially available, define an SLI that reflects successful user requests, then alert on meaningful error-budget burn rather than every internal component alarm.
AWS’s reliability design principles recommend recovery automation, testing recovery procedures, horizontal scaling, and capacity monitoring. Those are ways to reduce or recover from specific failures, not a universal recipe for every service. Microsoft’s reliability pattern catalog is a useful index for circuit breakers, bulkheads, health endpoints, and other options.
Quick recap checklist
- Choose the user-facing availability measure and define its success rules.
- Calculate the budget from an explicit period and maintenance policy.
- Separate required dependencies from features that can be omitted temporarily.
- Set database failover expectations using RTO, RPO, replication behavior, and tested recovery.
- Link alerts to a service objective and an action an operator can take.
Further reading
- Google SRE availability table shows time-based budgets and when request-based aggregation better represents partial outages.
- AWS reliability design principles cover recovery, recovery testing, horizontal scaling, and capacity.
- Microsoft reliability patterns indexes options such as circuit breakers, bulkheads, and health endpoints.
Interview questions
When a service is partially available or traffic varies. A request-based SLI measures the fraction of eligible requests that succeed instead of treating an interval as fully up or down.
8,760 hours multiplied by 0.001 gives 8.76 hours, or 8 hours, 45 minutes, and 36 seconds. The result is a budget under the chosen measurement rules, not an outage guarantee.
If checkout can complete without recommendations, omitting that feature keeps the core path available. A fallback and bounded calls reduce the dependency's impact; they do not restore it.
How failure is detected, who or what promotes a replica, the RTO and RPO, the possible effects of replication lag, how split brain is prevented, and how recovery is tested.
It can route around an unhealthy instance when healthy capacity remains. It does not remove shared dependencies or guarantee that the service can write to its database.
Category
Related Posts
The Eight Fallacies of Distributed Computing
Explore the classic assumptions developers make about networked systems that lead to failures. Learn how to avoid these pitfalls in distributed architecture.
Quality Attributes and Architecture Trade-offs
Turn goals like reliability, security, and performance into measurable scenarios, then compare architectural choices with explicit costs and constraints.
Distributed Systems Primer: Key Concepts for Modern Architecture
A practical introduction to distributed systems fundamentals. Learn about failure modes, replication strategies, consensus algorithms, and the core challenges of building distributed software.