Automation and Toil Reduction Questions
Deciding what manual, repetitive work is worth automating and proving it paid off. Covers identifying and inventorying toil, scoring and prioritizing automation candidates, break-even and ROI arithmetic including maintenance cost, choosing an automation approach (robotic process automation, scripts, no-code tools, rules engines, ML-assisted triage, self-service) and migrating legacy spreadsheet or macro processes, when not to automate, safeguards and governance for automation that touches production or business-critical processes (dry-run, approvals, audit trail, ownership, rollout and rollback), finding opportunities through ticket data or process-discovery analysis, measuring automation health and impact (including diagnosing regressions and attributing impact), cataloguing existing automations, making the business case to leadership, and managing the people side (adoption, reskilling, stakeholder concerns). Applies to operations, data and business-process work alike. Excludes writing the automation itself (scripts, infrastructure-as-code, pipelines, orchestrator internals), the definition of toil as reliability doctrine, and incident response mechanics.
Design a review gate for pull requests that introduce or change automation. What evidence would you require before it can touch production, and how would you keep the gate from becoming a rubber stamp?
Sample Answer
The idea in plain words
A review gate is a rule that a pull request (a proposed code change, reviewed before it merges) cannot reach production until named evidence exists and a qualified person has approved. For automation that acts on production, the gate has one job: make it cheap to show that the change is safe and expensive to approve without looking. A gate fails into a rubber stamp (approval without real review) when the only control is a reviewer reading a diff. So the design is: tier changes by blast radius (how much can be harmed if the change is wrong), require machine-produced evidence in the pull request, make a second person who owns the target verify it, and measure whether review is real.
Tier by blast radius
| Tier | Example change | Gate |
|---|---|---|
| 0 | Comment, docs, logging text | Normal review, CI (continuous integration) checks |
| 1 | Automation that only reads or reports | One reviewer, tests pass |
| 2 | Automation that changes reversible state in one non-production or low-impact scope | Evidence pack below, one reviewer from the owning team |
| 3 | Automation that changes or deletes production state, touches many targets, or changes permissions | Evidence pack, two approvers including the owner of the target system, staged rollout plan, named on-call owner |
Evidence required before Tier 2 and 3 can merge
- Scope statement: exactly which resources the automation can select, and the maximum number it may change in one run. The selector is the filter expression in the code that decides which resources the automation acts on (for example
state = unattached AND age_days > 30). The selector, not the prose description of it, is what counts: a reviewer who reads "cleans up old volumes" learns nothing about what it will match. - A dry-run output (a run that reports what it would do without doing it) from the real production target, attached by CI, showing the list of resources it would touch.
- Tests that include failure paths: partial failure, a retry, running twice (idempotency, meaning the second run changes nothing), an unavailable dependency.
- Rollback: how to undo it, and proof it was tried on a non-production copy. If the action cannot be undone (a delete), say so and require a backup or a soft-delete step (mark the resource for deletion and remove it only later, so a mistake can still be reversed in the meantime).
- Safety limits in the code: a cap on changes per run, a rate limit, a kill switch (one control, such as a feature flag, that stops the automation immediately), and a refusal to run when its inputs look wrong (for example an empty list from a source that normally returns hundreds).
- Permissions diff: the service identity (the account the automation runs as, kept separate from any person) should hold the least privilege needed (only the permissions the job requires, nothing more), and any widening is shown explicitly.
- Observability: a metric and an alert for what it did, and an audit log entry per action.
- Ownership: a named team and on-call rotation who will be paged, and a runbook link.
- Rollout plan: first run in dry-run in production, then a small scope, then wider, with the health signals that stop it.
Where to start: items 1, 2, 4, 5 and 8 can be checked by CI or a simple lookup from the first day, so a first version of the gate can enforce them. Items 3, 6, 7 and 9 need test reports, a permission comparison, dashboards and staged-rollout tooling, so they are added as that tooling exists, and until then the reviewer asks for them by hand.
What items 1 and 2 look like (illustrative)
A scope statement for the volume-cleanup job in the worked example below:
Selects: volumes in accounts prod-eu and prod-us with
state = unattached, age_days > 30, tag "keep" absent
Excludes: volumes whose instance was stopped within the last 60 days
Max per run: 25 deletions
Cannot touch: snapshots, any other account
The dry-run attachment that CI posts on the pull request (illustrative output of the job's own report-only mode):
mode=dry-run matched=38 cap_per_run=25 would_act_on=25 deferred=13
volume account age_days instance_state
vol-0a1 prod-eu 41 terminated
vol-0b7 prod-us 95 terminated
(36 more rows)
The reviewer compares matched=38 with what the author said to expect and reads a few rows to see whether they are plausible deletions.
Keeping the gate from becoming a rubber stamp
- Replace judgement from the diff with evidence in the pull request. A reviewer checks the dry-run list against intent ("why are 400 volumes on this list when we expected 40?"), which is a question a human can answer.
- The approver must be someone who owns or operates the target system, not only a teammate. Enforce with code-owner rules (a file in the repository that names which team must approve changes to which paths, and the platform refuses to merge without that approval). The author never approves their own change.
- Cap the size. Large diffs are skimmed; ask for small changes, or split the automation from the config that points it at production.
- Make review time visible and fair: reviews are counted as work, with a queue, so approving fast is not the way to stay unblocked.
- Machine-check the checklist: CI fails if the dry-run artifact, test report or rollback note is missing. Humans review judgement, machines review presence.
- Test the gate itself with seeded defects (flaws planted on purpose): every quarter, a security or platform engineer submits a deliberately flawed Tier 3 change (for example, a selector that also matches a production tag) and records whether reviewers catch it. Track the catch rate over time.
- Track warning signs: median time to approve on Tier 3 changes, share approved with no comments, and post-merge incidents traced to approved changes.
- The gate is not the only defence. Runtime limits and staged rollout exist because review will sometimes miss.
Worked example: two pull requests
Pull request A changes a retry count in a weekly reporting script. It reads data only, so it is Tier 1: one reviewer and passing tests. Total effort: minutes.
Pull request B adds a job that deletes unattached storage volumes older than 30 days across all production accounts. Tier 3. The author attaches a dry-run listing 412 volumes. The owning team's reviewer expected roughly 40 and asks why. The cause is that, in this inventory, "unattached" also matches volumes whose instance is stopped, and some instances are stopped between monthly jobs and restarted each month. A rule of "older than 30 days" therefore catches disks that sit idle for a month but are still needed. The selector is changed to exclude volumes whose instance was stopped within the last 60 days, which covers two full monthly cycles, so a monthly restart is never mistaken for abandonment. The cap is set to 25 deletions per run. Deletion becomes two-phase: take a snapshot (a saved copy of the volume's contents) and mark the volume for deletion, then delete the volume 7 days later if nobody has objected, so a wrong delete can be restored from the snapshot during that week. The second dry-run lists 38 volumes, which the cap clears in two runs (25, then 13). Here the gate worked because the evidence made a wrong scope visible; a diff of the selector alone would have looked fine.
Seeding arithmetic
Suppose 8 seeded flawed changes are submitted in a quarter and reviewers catch 5. The catch rate is 5 / 8 = 62.5 percent. With only 8 trials the uncertainty is wide, so treat it as a signal to look at the 3 misses and what evidence would have made them visible, not as a precise score.
Pitfalls
- A long generic checklist everyone ticks without reading.
- The same two people always reviewing each other.
- A gate with no emergency path: people bypass it informally. Provide an audited emergency route with after-the-fact review.
- Measuring the gate by speed alone, which rewards the rubber stamp.
How do you validate automation that modifies stateful resources such as databases, load balancer configuration or schema before trusting it in production? How would you test its behavior under partial failure and dependency outages?
Sample Answer
The idea in plain words
Automation that changes stateful resources (a database, a load balancer's pool of servers, a schema) is dangerous because a mistake persists: restarting a stateless web server is undone by the next restart, but a deleted row or a dropped backend stays gone. Trust is earned in layers: design the automation so repeats and crashes are safe, test it on a disposable copy of production-shaped data, deliberately break its dependencies and watch that it stops instead of guessing, then release it in small steps. The central rule for partial failure is that "I could not find out" must never be treated as "the answer is bad".
Validation ladder, in order
- Design properties checked in review
- Idempotent: running it twice leaves the same end state as running once.
- Preconditions: it checks the state it expects before every change and refuses if reality differs (compare-and-set: change only if the value is still what you read).
- Small, bounded steps: a cap on how many resources it may change per run and a floor such as "never fewer than 4 healthy backends".
- Resumable: if it crashes between step 2 and 3, a rerun detects where it stopped.
- Single writer: a lock or lease (a lock that expires) so two copies cannot act at once, with a fencing token (a number that increases each time the lock is granted, rejected by the target if stale).
- Timeouts and bounded retries with backoff (waiting longer after each failed attempt, for example 1 second, then 2, then 4). A timeout is ambiguous: the write may or may not have happened, so the next step is to read the state, not to repeat blindly.
- Reversible changes: for schemas, use expand then contract (add the new column, write to both, migrate, switch reads, drop the old one later), so each step is backward compatible.
- Plan or dry-run output against production, reviewed by a person who owns the resource.
- Execution on a restored backup or clone of production shape. Restoring the backup is itself a test of your recovery. Measure what matters on production-sized data: how long locks are held, how many rows change.
- Fault injection (deliberately causing a failure to see how the automation reacts) in a test environment (below).
- Production canary (a first, small slice of real production, run before everything else): one pool or one shard, with limits, and a person watching.
Which properties matter when, with a trace
Three properties belong in every stateful automation: idempotent, preconditions (compare-and-set) and small bounded steps with a floor. The others each answer one specific hazard, so add them when the hazard exists: resumable when a run has several steps that can stop halfway; a single writer (lease plus fencing token) when two copies could ever run at once; bounded retries with backoff when a dependency can be slow; expand then contract when the change is to a schema.
Compare-and-set with a concrete value: an order row reads pending, the automation plans to set it to archived, but another process sets it to paid first. The automation's update says "set archived where status is still pending", so it changes 0 rows and stops instead of overwriting paid.
Fencing token with concrete numbers: copy A holds the lock with token 32, then stalls (a long pause in the process or the virtual machine) and its lease expires. Copy B is granted the lock with token 33 and writes. When A wakes up it still believes it holds the lock and writes with token 32. Without the token the stale write would land after B's. The target remembers the highest token it has accepted (33) and rejects 32.
import sqlite3
# Compare-and-set: change a row only if it still has the value that was read.
db = sqlite3.connect(":memory:")
db.execute("CREATE TABLE orders (id INTEGER PRIMARY KEY, status TEXT)")
db.execute("INSERT INTO orders VALUES (7, 'pending')")
seen = db.execute("SELECT status FROM orders WHERE id = 7").fetchone()[0]
db.execute("UPDATE orders SET status = 'paid' WHERE id = 7") # another process acts first
changed = db.execute(
"UPDATE orders SET status = 'archived' WHERE id = 7 AND status = ?", (seen,)
).rowcount
print("automation read:", seen, "| rows it changed:", changed)
print("final status:", db.execute("SELECT status FROM orders WHERE id = 7").fetchone()[0])
# Fencing token: the target remembers the highest token it has accepted.
class Target:
def __init__(self):
self.highest = 0
def write(self, token, value):
if token < self.highest:
return f"rejected {value!r}: token {token} < highest seen {self.highest}"
self.highest = token
return f"accepted {value!r}: token {token}"
target = Target()
print("copy A (token 32) writes:", target.write(32, "drain backend 3"))
print("lease expires, copy B gets token 33")
print("copy B (token 33) writes:", target.write(33, "drain backend 3"))
print("copy A wakes up late (token 32):", target.write(32, "drain backend 5"))
Output:
automation read: pending | rows it changed: 0
final status: paid
copy A (token 32) writes: accepted 'drain backend 3': token 32
lease expires, copy B gets token 33
copy B (token 33) writes: accepted 'drain backend 3': token 33
copy A wakes up late (token 32): rejected 'drain backend 5': token 32 < highest seen 33
Reading the output: the first two lines show the conditional update changing 0 rows, so the row keeps the value paid. The last four lines show token 32 accepted when it was the newest, token 33 accepted next, and the late write with 32 rejected because 32 is below the highest seen, 33.
Expand then contract on a concrete column: renaming users.fullname to users.display_name. A one-step rename breaks every running copy of the old code that still reads fullname. Instead: (1) add display_name as an optional column, which old code ignores; (2) deploy code that writes both columns; (3) copy existing values across in small batches; (4) switch reads to display_name; (5) after a quiet period, stop writing fullname and drop it in a later release. At every step both the previous and the next version of the code work against the schema, so a rollback at any step is safe.
Partial failure and dependency outages: what to test
| Fault | What the automation must do |
|---|---|
| Crash between two steps | On restart, detect the half-done state and finish or roll back; never repeat the first step blindly |
| Timeout on a write | Read back the state before retrying |
| Metrics or health source unreachable | Treat as unknown, take no destructive action, alert |
| Target API slow or rate limited | Back off; do not queue unbounded work |
| Two instances run together | The lock or lease rejects the second; a stale holder is rejected by its fencing token (a counter the lock issues, which the target refuses if it is older than the last one seen) |
| Input list unexpectedly empty or huge | Refuse and alert (limits on both ends) |
| Dependency returns stale data | Check data age; refuse if older than a threshold |
Fault-injection experiment: network partition between the automation and its health data
Scenario (assumed): automation removes a backend from a load balancer pool when its health check fails. The pool has 6 backends. The automation reads health from a metrics API at 192.0.2.10 port 9090. That address sits in the range 192.0.2.0/24, which RFC 5737 sets aside for documentation examples, so it can never be a real host; in a real test, use the address of your own metrics API.
Steady-state hypothesis (a measurable statement of what normal looks like and what you expect to stay true while the fault is active): at least 4 of 6 backends in the pool, error rate within 0.5 percentage points of baseline, and zero removal actions that the automation was not entitled to take.
Experiment, run first in staging, then on one low-risk production pool:
sudo iptables -A OUTPUT -p tcp -d 192.0.2.10 --dport 9090 -j DROP
sudo systemd-run --on-active=10m iptables -D OUTPUT -p tcp -d 192.0.2.10 --dport 9090 -j DROP
Flags: iptables edits the Linux firewall; -A OUTPUT appends a rule to the OUTPUT chain, the list of firewall rules checked in order for packets leaving this host (run it on the host where the automation runs, so traffic from it to the metrics API is dropped); -p tcp matches TCP; -d 192.0.2.10 matches that destination; --dport 9090 matches the destination port; -j DROP silently discards matching packets, which looks like a partition (timeouts) rather than a refused connection. The second command uses systemd-run --on-active=10m to schedule the identical rule with -D (delete) after 10 minutes, so the partition heals itself even if your session is lost.
Procedure and expected behaviour, as a timeline (minutes from start):
- 0:00 steady state; 6 healthy backends.
- 2:00 partition begins. The last good health read is at 2:00.
- 3:00 backend 3 genuinely fails (stop its service by hand).
- 3:30 the automation's staleness limit of 90 seconds is exceeded. Expected: it logs "health data stale", raises an alert, and takes no removal action. It does not drain backend 3 yet, because it cannot know.
- 12:00 the partition heals (10 minutes after the rule was added at 2:00).
- 12:30 first fresh read. Expected: it removes backend 3 exactly once; 5 healthy remain.
Failure the experiment is built to expose: an automation that treats missing data as unhealthy would, at 3:30, try to drain all 6 backends. The floor of 4 healthy would stop it after 2 removals (6 minus 2 = 4), but removing 2 healthy servers still hurts, which is why the floor is the second defence and "unknown means hold" is the first.
Abort criteria (stop the experiment and heal the partition at once, by running the delete command manually): error rate more than 1 percentage point above baseline for 2 minutes, healthy backends below 4, or any removal action during the partition. A removal during the partition also means the hypothesis failed, whatever the user-facing impact.
Pass means: the hypothesis held in staging and in the canary pool, the alert fired, and exactly one removal happened after healing. Repeat the experiment after any change to the automation's decision logic.
Judgment
I would not trust the automation in production until it passes: dry-run review, a restored-copy run, the partition experiment, and one canary pool. What would slow me down: irreversible actions without a backup, no way to read state back, or a source of truth that the automation itself cannot verify.
Mistakes
- Testing only the success path.
- Retrying a timed-out write without reading state.
- Floors and caps that exist in the design but are never exercised by a test.
- Experiments with no abort condition or no scheduled heal.
Running the code
Python 3.12, standard library only: save the program as cas_fencing.py and run python cas_fencing.py.
Design a centrally discoverable automation catalog that stores metadata (owner, health metrics, SLOs, runbook links, deprecation date), provides searchable UI and API, and integrates with CI/CD to update health and test results automatically. Explain owner verification, stale-entry detection, and notification workflows.
Sample Answer
The idea in plain words
An automation catalog is a registry that answers four questions about every piece of automation the organisation runs: what is it, who owns it, is it healthy, and when does it end. Without one, automations accumulate until nobody knows which cron jobs and bots exist, and the ones that break are found by their victims. The design hinges on one decision: the catalog must be fed by the places where truth already lives (the repository, the CI/CD pipeline, the scheduler, the identity directory), because a registry that depends on people remembering to edit a form goes stale over time.
What an entry holds
| Field | Source of truth | Notes |
|---|---|---|
id, name, description | Declared in the repo | The id is stable across renames |
owner | A team or group in the identity directory (the organisation's central list of people, groups and service accounts) | Never a single person |
tier | Declared, validated | Blast radius, meaning how much damage a mistake can do. Tier 0 writes production data or customer-facing state and is hard to reverse, tier 1 writes production infrastructure and can be reversed within minutes, tier 2 is read-only or non-production. A lower number means higher risk |
slo | Declared | A service level objective: a target for how well the automation should perform. For example, "completes within 30 min, 99 percent of scheduled runs" |
runbook_url | Declared | Link checker verifies it resolves |
health: last run, last success, success ratio over 30 days, last test result | Pushed by CI/CD and the scheduler | Never typed by a person |
deprecation_date | Declared, optional | Set when retirement is planned |
repo, commit, version | Pipeline | Links entry to code |
Registration is catalog-as-code: the catalog's entries live as small files in each automation's own repository instead of in a web form. Each repository holds a file such as the one below, and a CI check (an automated check that runs on every proposed change) fails the build if it is missing or invalid. Creating an automation without a catalog entry becomes impossible rather than discouraged.
id: cert-rotation-edge
owner: team-edge-platform
tier: 1
slo: "completes within 30 min, 99% of scheduled runs"
runbook_url: https://wiki.example.com/runbooks/cert-rotation-edge
deprecation_date: null
Architecture
- Store: a database with the entry, plus a time series of health events.
- API: read endpoints for search and filter (by owner, tier, health, deprecation), and write endpoints used only by service identities (accounts that belong to programs such as the pipeline and the scheduler, not to people), so health data cannot be hand-edited.
- UI: a search page with filters and a detail page per entry, linking to the runbook, the repo and recent runs. Owners see their own entries on a dashboard.
- CI/CD integration: on every merge, the pipeline syncs the declared fields; after every test run and scheduled run, it posts the result with the commit and run ID.
- Directory sync: a periodic job resolves each
owneragainst the identity directory.
Owner verification
Verify ownership three ways, because each one fails differently:
- Existence: the group exists and has at least 2 members (a one-person group is a single point of failure). A group that is empty or deleted marks the entry ownerless immediately.
- Reachability: each quarter the catalog sends the owner group a request to confirm "still yours, still needed". A confirmation (an attestation: a recorded statement from the owner that the entry is still theirs and still needed) updates
last_attested, the date of the latest one; silence escalates. - Authority: only members of the owner group, or catalog admins, can change an entry's declared fields, enforced by the repository's code-owners rule (a file naming which group must approve changes to which paths, which the platform enforces at merge) on the catalog file.
Stale-entry detection
An entry is stale if any rule trips. The thresholds below are starting values to tune against your own runs.
| Rule | Condition |
|---|---|
| Not running | Time since last run exceeds 2 times the expected interval |
| Failing | No successful run or passing test for 30 days |
| Abandoned | No commit for 12 months and no attestation within the last quarter |
| Ownerless | Owner group missing or empty |
Applied to three assumed entries on the same day:
- Entry A runs daily, last run 3 days ago. Threshold is 2 x 1 day = 2 days. 3 > 2, so stale (not running).
- Entry B runs weekly, last run 9 days ago. Threshold is 2 x 7 = 14 days. 9 < 14, so healthy on this rule.
- Entry C is healthy by every run metric, but its owner group has 0 members. Ownerless, regardless of health.
Notification workflow
A ladder with a clock, so stale entries get resolved instead of ignored. Day 0 is the day a rule first trips. The recipient of the first message is the owner group; for an ownerless entry the owner group has nobody to read it, so the ladder starts one level up: the message goes to the catalog admins and to the manager of the team named in the repository's code-owners file or, failing that, of the last committer, and that person must assign a new owner group.
- Day 0: message the owner group (or, if ownerless, the people above) with the rule that tripped and a link to the entry.
- Day 7: post to the owning team's channel and notify their manager.
- Day 14: the catalog opens a change to the entry's file in its repository that sets
deprecation_dateto day 14 + 30 = day 44, so the declared field is still changed through the repository and its code-owners rule, and notifies every known consumer (for instance, other entries or pipelines that reference this automation's ID). - Day 44: automatically disable scheduled runs (for tier 0 and tier 1, the tiers that write to production, require a named approver to confirm first); keep the entry and code in an archived state.
Any owner response, such as "needed, fixing by Friday" with a date, pauses the ladder until that date. Without that pause, the ladder trains people to ignore it.
Judgment
Build the smallest useful version first: catalog-as-code, the CI check, health push from the pipeline, and the staleness report. A fancy UI on top of empty or wrong data adds nothing. What would change this: if the organisation already runs a developer portal, add these fields and checks to it instead of building a second registry.
Common mistakes
- Making people fill a form, then discovering months later that many entries are wrong.
- A person as owner, which breaks when they change teams.
- Alerts that go to a channel nobody reads; the ladder must reach a manager.
- Deleting stale entries instead of archiving, which loses the history that auditors and incident responders need.
Draft a controlled rollout plan for automation that modifies production infrastructure (for example, automated scaling rules). The plan should include testing stages, rollout percentages, automated health checks, rollback criteria, runbook readiness, and stakeholder notifications and approvals.
Sample Answer
The idea in plain words
Automation that modifies production infrastructure, such as a scaling rule that adds or removes servers, can fail by doing the wrong thing at full speed everywhere. A controlled rollout limits the harm by exposing the change to a small, chosen slice first (this slice is the blast radius, the amount that can be damaged), watching agreed health signals for long enough to see problems, and promoting to the next slice only when pre-agreed numbers say so. Each stage needs a rollback trigger written as a number, and a rollback that has been practised.
The plan
Stage 0: offline checks
- Review the rule and its limits: minimum and maximum instance counts per group, maximum change per step (for example no more than 10 percent of a group removed per 10 minutes), cooldown (a pause after each action so metrics can settle). A group here means one autoscaling group: a set of servers that the rule resizes together.
- Replay a week of historical load through the rule in a simulator or a test harness and count how many scale actions it would take and how often it oscillates (flaps: scaling out then in repeatedly, usually because the out and in thresholds are too close).
- Unit tests for the arithmetic, and a test that the rule refuses to scale below the minimum.
Stage 1: synthetic load in a test environment
Apply the rule and push load that ramps up, spikes and falls. Confirm scale-out latency is within what traffic needs, scale-in does not remove capacity during a dip that is followed by a peak, and the limits hold.
Stage 2: shadow (recommend-only) in production
The rule runs against live metrics but only logs what it would do. Run for a full weekly traffic cycle. Compare its decisions with what the current rule did.
Stage 3 to 6: staged enablement
Enable on a growing slice of groups, chosen from low-risk to high-risk. Between stages a bake time (the minimum time to watch before promoting) must cover at least one daily traffic peak.
Why the unit is a group and not a share of traffic: a scaling rule does not act on requests, it decides how many servers a group should have. A group cannot run a rule for 5 percent of its requests, so the smallest honest slice is one whole group. A traffic percentage fits a change to request-handling code, where a router can send 5 percent of requests to the new version. Groups also give a built-in comparison: at the same hour, enabled groups can be compared with groups that are not enabled yet.
Automated health checks at every stage
Compare each enabled group with its own baseline (that group's normal readings from previous weeks at the same time of day) or with groups not yet enabled:
- error rate: roll back if it exceeds baseline by more than 0.5 percentage points for 5 minutes
- 99th percentile latency (the value 99 percent of requests are faster than): roll back if above 1.25 times baseline for 10 minutes
- flapping: roll back if more than 4 scale actions in an hour for one group
- capacity floor: stop if healthy instances fall below the minimum, or utilisation (the share of capacity in use, such as CPU busy percent) stays above 85 percent for 10 minutes
- cost guard: stop if instance count exceeds 1.5 times the forecast for the group (the instance count the capacity plan, or the same hour in previous weeks, says the group needs)
These thresholds are illustrations; tune them from your own baselines.
What a trip looks like, for one group with assumed baselines: error rate 0.4 percent, 99th percentile latency 240 ms, minimum 12 instances, forecast 20 instances.
| Check | Trigger value for this group | Reading that trips it |
|---|---|---|
| Error rate | 0.4 + 0.5 = 0.9 percent (0.5 percentage points is added to the baseline, not 50 percent of it) | 1.1 percent for 5 minutes in a row |
| p99 latency | 1.25 x 240 = 300 ms | 310 ms for 10 minutes |
| Flapping | More than 4 scale actions in an hour | The 5th action in the same hour |
| Capacity floor | Fewer than 12 healthy instances | 11 healthy |
| Cost guard | 1.5 x 20 = 30 instances | 31 instances |
A reading of 0.8 percent errors does not trip the first check (0.8 is below 0.9), which is why the latency and flapping checks exist alongside it. When the 1.1 percent reading holds for 5 minutes, the flag switches the rule off for that group, capacity is pinned at the last known good number (here 20 instances), and the on-call person is paged. Alert on the health checks and, where safe, let them switch the rule off automatically, because a person may not be watching.
Runbook readiness
Before stage 3, the runbook (a step-by-step document for responders) says: how to disable the rule (a feature flag, meaning a configuration switch that turns the rule on or off without redeploying code, tested), how to pin capacity manually to a known good number, who is on call, what each alert means, and how to reach the owner. A person who did not write the rule must perform the rollback in a drill and time it; target under 5 minutes.
Stakeholders, notifications and approvals
- Approval: the owning service team approves each stage promotion; the platform owner approves the plan; for services with customer commitments the service owner confirms the stage dates.
- Notify before each stage in the channel the on-call teams watch (what changes, when, the rollback switch, who to contact), and after each stage with the result.
- Record the change in the change system so it appears in an incident timeline.
Worked example (all numbers are assumed)
A fleet (the whole set of servers a team runs) of 200 instances in 10 groups of 20. Stages 0 and 1 touch no production instances. Plan:
| Stage | Scope | Instances | Share of fleet | Bake time |
|---|---|---|---|---|
| 0 | Offline review, replay, unit tests | 0 | 0% | 2 days |
| 1 | Synthetic load in a test environment | 0 | 0% | 3 days |
| 2 | Shadow, all groups | 0 changed | 0% | 7 days |
| 3 | 1 low-risk group | 20 | 20 / 200 = 10% | 3 days |
| 4 | 3 groups | 60 | 60 / 200 = 30% | 3 days |
| 5 | 6 groups | 120 | 120 / 200 = 60% | 3 days |
| 6 | All 10 groups | 200 | 100% | 7 days watch |
Elapsed time from the start of shadow mode to the end of the final watch: 7 + 3 + 3 + 3 + 7 = 23 days. Including stages 0 and 1, the whole plan takes 2 + 3 + 23 = 28 days. If stage 3 trips the latency trigger on day 2, the rule is switched off for that group, only 20 of 200 instances (10 percent of the fleet) were ever exposed, and the rest never ran the new rule. Without staging, the same defect would have hit all 200 at once.
Promotion rule: a stage is promoted only after its full bake time with no trigger, covering at least one daily peak. Do not promote on a Friday afternoon, or immediately before a freeze (a period in which only emergency changes are allowed), because the person who must watch the next stage may not be there.
Failure modes
- A healthy-looking stage on a quiet day: bake times and peak coverage exist for this.
- A metric outage: if health data is missing, treat that as "unknown" and hold, not as "healthy".
- A correct rule, a provider that cannot supply capacity: the rollback keeps the old minimum capacity.
- A rollback that also fails: keep manual pinning as a second path.
A team runs a manual 30-minute backup verification every morning to ensure backups are restorable. Outline an end-to-end automation plan to remove this daily toil. Cover success criteria, scheduling, verification artifacts, alerting on failures, rollback or fail-open behavior if automation fails, and how you would measure and present reduction in toil.
Sample Answer
The idea in plain words
Toil is manual, repetitive work that follows a rule, grows with the service and leaves nothing lasting behind; a 30-minute check done by hand every morning is a clear example. The manual task exists to answer one question every morning: "if we lost the database today, could we get it back?" A backup is only useful if it can be restored (restored means turned back into a working copy of the data), so the check must restore and inspect, not merely confirm that a backup file was written. Automating it means a scheduled job that restores the latest backup into a throwaway environment, runs defined checks, stores a report, and alerts a human when something is wrong or when no result arrives. The plan below follows the order of the questions asked: success criteria, scheduling, verification artifacts, alerting, failure behaviour, and how to measure and show the toil reduction.
Two terms used below. RPO (recovery point objective) is how much data loss the business accepts, expressed as time, for example 24 hours means the newest usable backup must be less than 24 hours old. RTO (recovery time objective) is how long a restore is allowed to take. The numbers here are assumptions for the example: RPO 24 hours, RTO 4 hours.
1. Success criteria
A run is a pass only if every one of these holds, and each is measurable:
- The newest backup is younger than the RPO (24 hours).
- The restore completes without error into an isolated scratch environment (a temporary, separate copy of the infrastructure that is thrown away afterwards).
- The restore finishes within the RTO budget (4 hours). A restore that takes 5 hours is a failure even if the data is perfect.
- Integrity checks pass: the backup file's checksum (a short fingerprint computed from the file's bytes; if one byte changes, the fingerprint changes) matches the one recorded when it was written, and row counts or object counts for chosen tables fall within an expected band against the source. For example, if the orders table had 1,250,000 rows when the backup was taken, the restored copy should have 1,250,000, and a count outside, say, 1% of that fails the check.
- An application-level check passes: a small set of read queries returns expected results, for example the latest order is present and a key table is non-empty.
Start by making the automation at least as thorough as the human check. If the person only looked at a job status page, the automation should do more than that, but first write down what the manual check really covers, so that nothing it caught is dropped.
2. Scheduling
Trigger the verification when the backup job finishes (an event or a dependency in the scheduler), with a time-based fallback. Assume backups finish by 03:00 and verification starts at 04:00. A typical restore takes about 1.5 hours (assumed), so the report usually lands around 05:30. The hard limit is the RTO: start plus 4 hours is 08:00, and a run still going then is stopped and counted as a failure. A "started" heartbeat (a small signal the job sends when it begins) is expected by 04:15. Do not simply start at a fixed time and hope the backup is done: a verifier that tests yesterday's backup and reports green hides that today's failed. Run the restore in an isolated environment with no route to production, cap its cost and run time, and tear it down afterwards. Keep a weekly deeper test, for example a full restore of the largest database, in addition to the daily lighter one, if the daily one samples.
3. Verification artifacts
Each run writes one report, kept for a retention period that fits the audit need, for example 13 months:
- run identifier, start and end time, backup identifier and its timestamp,
- checksum expected and observed, restore duration, restored size,
- each check with pass or fail and the value observed,
- link to the logs and the scratch environment's teardown confirmation.
A short machine-readable summary (a JSON file) feeds the dashboard; the full logs are linked from it. This replaces a person's recollection with evidence anyone can open. An illustrative summary (invented values):
{
"run_id": "2026-10-29-0400",
"backup_id": "orders-2026-10-29-0230",
"backup_age_hours": 1.5,
"restore_minutes": 95,
"checksum_match": true,
"checks": [
{"name": "orders_row_count", "expected": 1250000, "observed": 1249870, "pass": true},
{"name": "latest_order_present", "pass": true}
],
"result": "pass"
}
4. Alerting
- Failed check or restore: a high-priority ticket during business hours (a ticket is a tracked work item that someone picks up in working hours); a page (an automatic call or message to the on-call person's phone, even at night) if it is the second consecutive failure or if the newest usable backup is older than the RPO.
- No report by 08:30 (a dead-man's switch, meaning an alert that fires when an expected signal does not arrive): the verifier itself has failed to run. The time is the latest legitimate finish, 08:00, plus a 30-minute margin, so a slow but valid 3.5-hour restore does not trip it. A missing "started" heartbeat at 04:15 raises the same alert early. This is the most important alert, because silence otherwise looks like success.
- Slow restore trend: a ticket, not a page, when restore time exceeds 75% of the RTO budget (3 hours of 4, so a run still going at 07:00).
5. Rollback and fail-open behaviour if the automation fails
The verifier only reads backups and writes to a scratch area, so a failure of the verifier cannot damage the backups or production: the backups keep running regardless (that is the fail-open part, the verification being a monitor and not a gate). What must not happen is a failure that looks like a pass. So: no result is treated as a failure, never as a green; a crashed verifier alerts through the dead-man's switch; and on such a day a person runs the old manual check as the fallback. For the rollout, run the automation in parallel with the manual check for 10 working days and compare results; only stop the manual check after the two agree. Keep the manual procedure written down and rehearse it once a quarter.
6. Measuring and presenting the toil reduction
Assumptions: the manual check takes 30 minutes on each of 260 working days per year; the automation costs 24 hours to build; the parallel run costs 10 days x 0.5 hours = 5 hours of manual checking; maintenance is 12 hours per year; and 15 failures per year need a person for 20 minutes each.
| Item | Hours per year |
|---|---|
| Manual toil removed: 260 x 0.5 | 130 |
| Maintenance | 12 |
| Human time on automation exceptions: 15 x 20 / 60 | 5 |
| Net saved per year: 130 - 12 - 5 | 113 |
Upfront cost = 24 + 5 = 29 hours. Payback = 29 / 113 = 0.26 years, about 13 weeks of operation (0.2566 x 52 = 13.3).
If the team actually checked on 365 days, the saving would be larger; the 260 figure is a stated assumption. Present: a before and after table of hours, the payback date, and outcome measures that matter more than hours: share of days with a verified restore (target 100%), time from a backup failure to detection (hours before, minutes after), and restore duration against the RTO. Report what the freed hours were used for, and report the maintenance honestly.
Judgment
I would build it, because the check is daily, rule-based and read-only with respect to production, so the harm is low and the payback is about a quarter. I would keep a human fallback and a quarterly manual rehearsal. What would flip it: if restores need manual steps that cannot be scripted (for example hardware media loaded by hand), I would automate the status and age checks first and keep the restore test as a weekly manual drill.
Common mistakes
- Verifying that the backup job reported success instead of restoring.
- No dead-man's switch, so a dead verifier looks like green.
- Restoring into an environment connected to production.
- Counting the build time but not maintenance and exception handling.
- Retiring the manual procedure so completely that nobody remembers how to do it.
Unlock Full Question Bank
Get access to all 17 Automation and Toil Reduction interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.