Skip to content
$ lynuxpro
← SRE Practices

LESSON 2 OF 17 · BEGINNER · 11 MIN

Toil and automation

Free previewLesson 2 of the 2 free lessons in this Pro course.Unlock all 17

HOW IT WORKSFrom manual task to automation

Toilmanual, repeatedMeasurehours per weekRanksaving vs build costAutomatescript, self-serviceTime for engineeringbetter systems
1/5

Toil is manual, repetitive work that grows with the service.

restart worker by hand, daily

In simple words

  • Toil: manual, repetitive work that grows with the system and has no lasting value, such as restarting the same service by hand.
  • Automation: replacing toil with tools and scripts so it never needs a person again.
  • Automation ladder: the steps from a written runbook, to a script, to a self-service tool, to full self-healing.

Big picture

Toil is work that keeps a service running but does not make it better. It is boring, manual and repeats forever. SREs try to measure toil and replace it with automation.

Picture washing dishes by hand every night. Buying a dishwasher costs money once, then saves time every day. Automation is the dishwasher.

What counts as toil

Work is toil when it is most of these:

SignMeaning
ManualA person types commands or clicks buttons
RepetitiveYou do it again and again
AutomatableA script could do it
TacticalIt reacts to something, no plan behind it
No lasting valueAfter you finish, the service is no better
Grows with the serviceTwice the users means twice the work

Toil or not?

TaskToil?Why
Restarting a stuck job by hand every dayYesManual, repeated, no lasting value
Resizing disks when they fill upYesReactive and automatable
Writing a script that cleans old logsNoEngineering work, it removes toil
Designing a new capacity planNoNeeds judgment, has lasting value
Responding to a new kind of outageNoNew and creative
Approving access requests by handYesRule-based, can be automated

Not all manual work is toil. Reading a new problem and thinking it through is engineering.

Measure it first

You cannot reduce what you do not measure. Keep a simple log for two or three weeks.

Task                         Count/week   Minutes each   Hours/weekRestart queue worker               14             6          1.4Rotate expired certificate          2            30          1.0Create user access                 25             8          3.3Clear full disk on db-3             3            20          1.0                                                   Total     6.7
OUTPUTterminalutf-8 · 6L

Then compare with your whole work time. If one person works 40 hours and spends 6.7 on these tasks, that is about 17% toil from this list alone.

Decide what to automate first

Use a simple rule: the savings should beat the cost.

time saved per year = count per year x minutes saved eachbreak-even          = time to build the automation
OUTPUTterminalutf-8 · 2L

Example: access requests take 8 minutes and happen 25 times a week.

25 x 8 min x 52 weeks = 10,400 minutes = about 173 hours per yearA self-service tool takes about 40 hours to build.It pays for itself in roughly 3 months.
OUTPUTterminalutf-8 · 3L

Also consider risk. Manual steps cause mistakes. A task that is rare but dangerous, like failing over a database, is worth automating even when the time saved is small.

The automation ladder

LevelExampleNotes
0. Tribal knowledge"Ask Sam, he knows"Fragile
1. Documented stepsA wiki page of commandsBetter, still manual
2. A scriptrestart-worker.shOne command
3. A script with checksVerifies health, rolls back on failureSafer
4. Self-serviceA button or bot, with approval rulesOthers can use it
5. Fully automaticThe system fixes itselfBest, when safe

Most toil should move up one step at a time. Do not jump to level 5 for something that nobody understands yet.

A small example

Before:

# every morning, someone runs this by handssh worker-1 "sudo systemctl restart queue-worker"ssh worker-2 "sudo systemctl restart queue-worker"
SHELLbashutf-8 · 3L

After, as a systemd rule so the system restarts the service itself:

# /etc/systemd/system/queue-worker.service[Service]ExecStart=/usr/local/bin/queue-workerRestart=on-failureRestartSec=5
NORMALconfutf-8 · 5L
$ sudo systemctl daemon-reload && sudo systemctl restart queue-worker$ systemctl show queue-worker -p RestartRestart=on-failure
OUTPUTterminalutf-8 · 3L

This removes a daily task. The next question is why the worker crashes at all, which is the real fix.

Automate the cause, not only the symptom

An auto-restart hides a bug. Keep a counter of how often it fires and look at it each week. If restarts keep climbing, the system tells you something is wrong.

Common mistakes

  • Automating a bad process. Fix or remove the step first.
  • Building a huge tool for a task that happens twice a year.
  • Scripts nobody else can read or run. Keep them in Git with a short README.
  • Never measuring, so nobody can show that toil went down.
  • Counting all manual work as toil. Thinking and design work is not toil.

Summary

  • Toil is manual, repetitive, automatable work with no lasting value.
  • Measure it, rank it, and automate where the saving is biggest.
  • Climb the ladder step by step: document, script, check, self-service, automatic.
  • Keep toil under about half of the team's time (lesson 01).
  • Next: lesson 03 covers how to see what your service is doing.

CHECK YOUR UNDERSTANDING

3 quick questions

  1. 1. Which task is toil?

  2. 2. A task takes 8 minutes and happens 25 times a week. What is the yearly time?

  3. 3. What is the best first step to reduce toil?

You've finished the free preview of SRE Practices

Upgrade to Pro to unlock the remaining 15 lessons, every practice lab and a certificate when you finish.

See plans