Sub topic 11
Planned maintenance, partial outages, and what counts as down
This chapter assumes you can already convert a nines target into a downtime budget, and that you know the difference between time-based and request-based measurement. It also assumes you can read short Python snippets. The arithmetic is simple. The hard part is deciding which events go into the numerator, and that decision often moves the reported number by a full nine.
Why "down" needs a definition
Earlier chapters treated a service as either up or down. Real systems are rarely that clean. A deploy takes one region offline for ten minutes. A bad cache node makes 8% of requests fail. A database failover makes every request take six seconds instead of 200 milliseconds. Each of these is an event that a reasonable person might or might not call downtime.
If you do not write the definition down, you will argue about it during an incident review, or worse, during a billing dispute. A usable definition answers four questions:
- Does a scheduled event count?
- Does a partial failure count, and how much of it?
- Does a slow response count as a failure?
- Whose point of view is used: the load balancer's, a probe's, or the user's?
Planned maintenance
Planned maintenance is downtime you chose. Examples are a schema migration that needs a table lock, a kernel patch that needs a reboot, or a version upgrade that cannot run two versions side by side.
There are two common ways to treat it.
- Excluded from the target. Many SLAs exclude "scheduled maintenance" announced in advance, usually with a cap such as four hours per month. This is a contractual convenience for the provider.
- Included in the target. Users do not care whether you planned the outage. If their checkout fails at 2 p.m., the cause on your calendar makes no difference to them.
A practical split is to use both. Exclude announced windows from the external SLA, if the contract allows it. Include them in your internal SLO and error budget, so that maintenance spends budget like any other risk.
Why exclusion can hide real problems
Exclusion creates an incentive to relabel. A team that is close to breaching its SLA may start "scheduling" fixes after the fact. Guard against this with rules the whole team can check:
- Maintenance must be announced a fixed time ahead, for example 72 hours.
- Windows have a maximum length and a maximum count per period.
- An event that overruns its window counts as unplanned for the overrun.
- Emergency patches are unplanned, even if you chose the time.
Reducing planned downtime
The best fix is to make maintenance not cause downtime. The usual techniques are rolling deploys, where you update one instance at a time behind a load balancer. Connection draining lets in-flight requests finish before an instance stops. Blue-green deployment keeps the old version running until the new one passes health checks. Expand-and-contract schema migrations let old and new code share one schema. The patterns chapter covers these in more depth. Here the point is accounting: every minute you remove from planned downtime is a minute of budget you get back without buying any hardware.
Partial outages
A partial outage is a failure that affects some users, some requests, some features, or some regions, but not all of them. There are two ways to count it.
Binary counting. A time slice, such as one minute, is either up or down. You pick a threshold. For example, a minute is down if more than 5% of requests failed. This is simple to explain and matches how many cloud providers write SLAs. It overstates a mild partial outage that crosses the threshold. It also hides a smaller one that stays below the threshold.
Weighted counting. A minute with 10% failed requests counts as 0.1 minutes of downtime. This is the same as request-based measurement, expressed in time units. It reflects user impact more faithfully and rewards partial mitigation, such as shedding load to protect the most important routes.
Which to choose depends on who reads the number. Contracts usually need binary thresholds because they are easy to audit. Internal engineering targets usually benefit from weighted counting because they respond to small improvements.
Worked example
The following program computes the same month of incidents under four policies. A 30-day month has 43,200 minutes.
from dataclasses import dataclass
MONTH_MINUTES = 30 * 24 * 60
@dataclass
class Incident:
minutes: float
impact: float # fraction of requests affected, from 0 to 1
planned: bool = False
def downtime_minutes(incidents, weighted, include_planned, threshold=0.01):
total = 0.0
for incident in incidents:
if incident.planned and not include_planned:
continue
if weighted:
total += incident.minutes * incident.impact
elif incident.impact >= threshold:
total += incident.minutes
return total
incidents = [
Incident(minutes=20, impact=1.0), # full outage
Incident(minutes=60, impact=0.10), # 10% of requests failing
Incident(minutes=30, impact=1.0, planned=True), # announced maintenance
]
policies = [
("binary, any impact, planned counted", False, True, 0.01),
("weighted, planned counted", True, True, 0.01),
("weighted, planned excluded", True, False, 0.01),
("binary at 50%, planned excluded", False, False, 0.5),
]
for name, weighted, include_planned, threshold in policies:
down = downtime_minutes(incidents, weighted, include_planned, threshold)
availability = 1 - down / MONTH_MINUTES
print(f"{name:38s} {down:6.1f} min {availability:.3%}")
# binary, any impact, planned counted 110.0 min 99.745%
# weighted, planned counted 56.0 min 99.870%
# weighted, planned excluded 26.0 min 99.940%
# binary at 50%, planned excluded 20.0 min 99.954%The same month reports 99.745% under the strictest policy and 99.954% under the most lenient one. That is more than one nine of difference, and no user experienced anything different. The lesson is that an availability number is meaningless without its counting policy attached.
What counts as a failure
Beyond total outages and error rates, several other situations need a rule.
| Situation | Typical rule | Reasoning |
|---|---|---|
| HTTP 5xx from the service | Failure | The service failed to do its job. |
| HTTP 4xx caused by a bad client request | Not a failure | The service behaved correctly. |
| HTTP 4xx caused by your own bug, such as a wrong 404 | Failure | The user could not get a correct answer. |
| Response slower than a latency threshold | Failure | A response that arrives too late is useless. |
| Correct response but stale or wrong data | Failure, if you can detect it | Availability here means "works correctly". |
| One optional feature is off, such as recommendations | Usually not a failure of the core service | Count it against a separate SLI for that feature. |
| Outage in a third-party dependency you do not control | Failure from the user's view | Users cannot tell whose fault it was. |
Latency as availability
The spine defines availability as the fraction of time or requests for which a service works correctly. A request that returns after 30 seconds technically succeeded, but most users have already left. Many teams therefore define a good request as one that returns a non-error response within a latency limit, such as 500 ms. A slow database failover then counts as an outage even though no request returned an error.
Degraded modes
Graceful degradation, such as serving cached prices when the pricing service is down, turns a full outage into a partial one. Decide in advance whether a degraded response counts as good. A common answer is that it counts as good for the core SLI, and you also track a degraded-response rate on its own so it does not go unnoticed.
Choosing the point of view
Where you measure changes what you see.
- Server-side metrics are cheap and precise, but they miss requests that never arrived, for example when DNS or the load balancer failed.
- Load balancer or edge metrics catch more, but still miss failures between the user and your edge.
- Synthetic probes send test requests on a schedule from outside. They detect total outages even when there is no traffic, but they test only the paths you scripted.
- Client-side metrics reflect the real user experience, but they are noisy and include user network problems.
For request-based SLIs, measure as close to the user as is practical. For low-traffic services, add probes so that a quiet period does not hide an outage.
Deciding whether an event counts
The following flow summarizes a typical decision. Your own policy may differ, but it should be this explicit.
Common mistakes
- Averaging across regions. If one of four regions is fully down, global error rate is 25%, but every user in that region has a 100% outage. Track availability per region or per customer segment as well as globally.
- Counting only the loudest minute. A long tail of 2% errors after a recovery can burn as much budget as a short total outage. Weighted counting catches this.
- Letting health checks define "up". A health endpoint that returns 200 while the database is unreachable will report perfect availability during an outage.
- Changing the policy mid-period. Redefining "down" after an incident makes trends useless. Version your definitions and change them at period boundaries.
Exercises
Exercise
A service handles steady traffic. In one 30-day month it has a 15-minute full outage and a 40-minute period where 25% of requests fail. There is also a 20-minute announced maintenance window with full downtime. Using weighted counting with planned maintenance excluded, how many minutes of downtime are counted, and what is the availability (to three decimal places as a percentage)?
Show answer
Full outage: 15 minutes. Partial outage: 40 × 0.25 = 10 minutes. Maintenance is excluded. Total is 25 minutes. Availability is 1 − 25 / 43,200 = 0.999421, which is 99.942%.
Exercise
A team's SLA excludes scheduled maintenance, but their internal SLO includes it. Give one reason for keeping both rules, and one risk of the exclusion that the team should control with written rules.
Show answer
Reason: the SLA exclusion lets the provider do necessary maintenance without paying penalties, while the internal SLO makes the team spend error budget on maintenance and so push toward zero-downtime techniques. Risk: relabeling unplanned outages as "scheduled" to avoid breaching the SLA. Controls include a required advance notice, a maximum window length and count, and treating any overrun beyond the announced window as unplanned.
Exercise
Why can a request-based availability number look excellent while users in one region experience a total outage?
Show answer
Request-based availability is aggregated over all requests. If the failing region sends a small share of total traffic, its failures are diluted by the successful requests from other regions. Tracking availability per region or per customer segment exposes the outage.