In one minute
- Six real-life server problems, worked through from start to finish: what you see, how you investigate, the real cause, the fix and what you do so it never happens again.
- This is where everything in the course comes together. Interviews ask "walk me through how you would debug...", and on-call shifts throw exactly these problems at you.
- Every incident follows the same pattern: get the service working again first, collect clues, test one idea at a time, keep people updated, then write down what you learned.
- 👉 On call, in interviews, and any time production breaks.
Think of it like: a fire crew. First put out the fire (restore service). Then find out how it started (root cause). Then fit smoke alarms (follow-up) so it does not happen again.
How to run an incident
- Get it working first. Restore service (roll back, switch to a backup, add servers) before you dig deep.
- Collect clues before changing things. Save logs and command output. A restart wipes the evidence.
- Guess, test, repeat. Make one guess, test it, and change only one thing at a time.
- Keep people informed. Post short updates: what is broken, what you are doing, when the next update comes.
- Write a blameless postmortem. Fix the system, not the person.
Remember it: Restore → Record → Test → Tell → Learn.
Scenario 1: "Disk full" and the app cannot save
What you see: the API returns 500 errors. The logs say No space left on device.
df -hdu -sh /var/logdf -h / # 100% useddf -i / # inodes finedu -sh /var/* | sort -h # /var/log is 22Gls -lhS /var/log/app | head # app.log 21Gsudo lsof +L1 # nothing deleted-but-openReal cause: the app log had no rotation rule, and debug logging was left on after an earlier incident.
Fix: empty the live log (: > /var/log/app/app.log), set logging back to INFO, and add a logrotate rule with maxsize.
So it does not happen again: disk alert at 80%; log rotation built into the base image; logs sent to a central system so they only need to stay on the server briefly.
Scenario 2: High CPU and slow responses
What you see: responses are five times slower than normal. Load average is 14 on a 4-core machine.
uptimetopps auxvmstat 1 5ps aux --sort=-%cpu | head -n 5 # java at 390% CPUtop -H -p 2211 # one thread at 100%vmstat 1 5 # us 95%, wa 0%: CPU bound, not diskusis 95% andwais 0% → the CPU is busy with the app itself, not waiting for the disk.
Real cause: a new release added a text-matching pattern (regex) that gets stuck working very hard on certain inputs.
Fix: roll back to the previous release right away (restore first), then reproduce it in staging. For Java, jstack thread dumps showed exactly which code the busy thread was running.
So it does not happen again: a performance test in the pipeline; autoscaling on CPU; alerts on the slowest requests (p99), not just averages.
Scenario 3: Out of memory and random restarts
What you see: the service restarts several times an hour, with no error in its own log.
free -mjournalctl -kjournalctl -k | grep -i "killed process"# Out of memory: Killed process 2211 (java) anon-rss:3.6Gsystemctl status orders # restarts countedWhy the app log is empty: the app did not crash by itself. Linux killed it (the OOM killer), so the app never got a chance to write anything. The evidence is in the kernel log instead.
Real cause: Java was allowed 3.5 GB on a 4 GB machine. That left too little memory for the operating system and everything else. Under load, the OOM killer stepped in. (In Kubernetes, this shows as OOMKilled with exit code 137.)
Fix: set Java's memory to about 70% of what is available (or -XX:MaxRAMPercentage=70 in containers), and make the machine or container limit bigger.
So it does not happen again: alerts on OOM kills and restart counts; memory dashboards for each service.
Scenario 4: Connection refused after a deploy
What you see: after a deploy, the load balancer marks every server as unhealthy.
systemctl status nginxss -tulpncurl -I http://localhostss -tulpn | grep 8080 # 127.0.0.1:8080 javacurl -s localhost:8080/health # OK locally- It works on the server itself, but it is listening on
127.0.0.1, so nobody else can reach it.
Real cause: a config change set server.address=127.0.0.1. The app only accepted connections from its own machine, so the load balancer's health checks were refused.
Fix: listen on 0.0.0.0 and redeploy. The servers turn healthy within a minute.
So it does not happen again: a test in the pipeline that calls the health check through the load balancer before sending real traffic; canary deploys (send a little traffic to the new version first).
Scenario 5: Timeouts that happen only sometimes
What you see: about 1 in 20 requests to the payments API times out.
dig +short example.comnc -zv 10.0.2.10 5432ss -sfor ip in $(dig +short payments.internal); do curl -s -o /dev/null -w "$ip %{http_code} %{time_total}\n" --resolve payments.internal:443:$ip https://payments.internal/health; doneThis loop tests each payments server directly. One of the three is slow.
Real cause: one server had a failing disk. Its health check still passed (it only checked that the program was running), but real requests got stuck.
Fix: take the bad server out and replace it.
So it does not happen again: deeper health checks that test real work (such as a database call); outlier detection in the load balancer or service mesh, so a slow server is removed automatically.
Remember it: "Works sometimes" usually means one bad server out of several. Test each one on its own.
Scenario 6: "Permission denied" in a CI deploy job
What you see: the GitLab deploy job fails with rsync: mkstemp failed: Permission denied.
whoamils -ld /optidReal cause: during an OS upgrade, the deploy user was re-created and got a new user ID number. Linux tracks owners by number, so the old files now belonged to "nobody" as far as the new deploy user was concerned.
Fix: sudo chown -R deploy:deploy /opt/app, and fix the user ID in the setup code.
So it does not happen again: create service users with fixed IDs in Ansible; deploys write to versioned release folders owned by the deploy user.
Your troubleshooting toolkit
| Question | First commands |
|---|---|
| Is it up? | systemctl status, ss -tulpn, curl localhost |
| What changed? | Deploy history, journalctl --since, dnf history, Git log |
| Resources? | uptime, free -m, df -h, vmstat 1 5, iostat -xz 1 |
| Errors? | journalctl -p err -b, app logs, dmesg |
| Network? | dig, nc -zv, curl -v, ss -s, tcpdump |
| Permissions? | id, ls -l, namei -l path, SELinux denials |
"What changed?" is the most powerful question in operations. Most incidents come right after a deploy, a config change or a jump in traffic.
Writing the postmortem
A short report written after the incident.
So the team learns and the same problem does not come back next month.
| Section | What goes in it |
|---|---|
| Summary | One paragraph: what happened, who was affected, for how long |
| Timeline | Times, from when it was spotted to when it was fixed |
| Root cause | The technical cause, and what made it worse |
| What went well / badly | How it was spotted, how the team responded, which tools helped |
| Action items | Clear fixes, each with an owner and a date |
Keep it blameless. Write "the deploy process allowed an untested config change", not "Ravi pushed a bad config". People hide mistakes when they fear blame, and then nobody learns.
Common mistakes
- Restarting before collecting clues.
- Debugging in production for an hour when a rollback would fix it in two minutes.
- Fixing only the symptom (emptying the log) and not the cause (adding rotation).
- Skipping the postmortem, so the same incident happens again next month.
Practice
- In your own words, describe the five steps of running an incident.
- For scenario 3, explain why the app log showed nothing.
- Design a health check that would have caught scenario 5.
- Pick one scenario and write a five-line postmortem summary with two action items.
Key takeaways
- In an incident, get the service working first, then find the cause.
- Save the clues before you restart anything.
- Ask "what changed?" early. Most problems follow a change.
- An app killed for using too much memory leaves no error in its own log. Check the kernel log.
- Finish every incident with a blameless postmortem and fixes that stop it happening again.